> ## Documentation Index
> Fetch the complete documentation index at: https://developer.kodexa.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Spatial

> Use spatial commands in the kdx CLI to query KDDB document content by position, finding nodes inside bounding boxes or listing boxes on a page.

Spatial commands query document content based on physical position on a page. Find nodes within a bounding box region or list all bounding boxes on a page.

## Subcommands

| Command        | Description                             |
| -------------- | --------------------------------------- |
| `spatial find` | Find nodes within a bounding box region |
| `spatial bbox` | List bounding boxes for nodes on a page |

## Spatial Find

Find content nodes within a rectangular region on a specific page.

```bash theme={null}
kdx document spatial find <file.kddb> --page N --region x1,y1,x2,y2 [flags]
```

### Flags

| Flag                   | Description                     | Default       |
| ---------------------- | ------------------------------- | ------------- |
| `--page N`             | Page number (1-based, required) |               |
| `--region x1,y1,x2,y2` | Region coordinates (required)   |               |
| `--type`               | Filter by node type             |               |
| `--tag`                | Filter by tag name              |               |
| `--max N`              | Maximum results                 | 0 (unlimited) |
| `--pretty`             | Pretty-print JSON output        | false         |

### Example

```bash theme={null}
kdx document spatial find doc.kddb --page 1 --region 0,0,300,100 --type line
```

```json theme={null}
{"nodeId":15,"type":"line","content":"Invoice Number: INV-2024-001","page":1,"bbox":{"x1":72,"y1":50,"x2":280,"y2":62}}
{"nodeId":16,"type":"line","content":"Date: January 15, 2024","page":1,"bbox":{"x1":72,"y1":65,"x2":250,"y2":77}}
```

## Spatial Bbox

List all bounding boxes on a page, useful for understanding page layout.

```bash theme={null}
kdx document spatial bbox <file.kddb> --page N [flags]
```

### Flags

| Flag       | Description                     | Default |
| ---------- | ------------------------------- | ------- |
| `--page N` | Page number (1-based, required) |         |
| `--type`   | Filter by node type             |         |
| `--pretty` | Pretty-print JSON output        | false   |

### Example

```bash theme={null}
kdx document spatial bbox doc.kddb --page 1 --type line --pretty
```

```json theme={null}
{
  "nodeId": 15,
  "type": "line",
  "content": "Invoice Number: INV-2024-001",
  "x1": 72.0,
  "y1": 50.0,
  "x2": 280.0,
  "y2": 62.0
}
```

<Tip>
  Use `spatial find` to extract content from specific regions of a page, such as headers, footers, or specific form fields.
</Tip>

<Tip>
  Use `spatial bbox` to understand the layout of a page before targeting specific regions with `spatial find`.
</Tip>
