Source: https://gometry.monicz.dev/quickstart/

# Quickstart

Find which blocks intersect a station's 500-meter radius, then cover the area
with [H3](https://h3geo.org/) cells. Requires **CPython 3.11 or newer** — see
[Installation](https://gometry.monicz.dev/installation/) to install `gometry` (`uv add gometry` or
`pip install gometry`).

## 1. Create a station

Create a [`Point`](https://gometry.monicz.dev/api/geometry-types/#gometry.Point "Point") in WGS 84 (`EPSG:4326`) with a Chart
[`Space`](https://gometry.monicz.dev/api/crs/#gometry.Space "Space"):

```python
import gometry as gm

geographic = gm.Space(crs=4326, model="chart")
station = gm.Point(2.2945, 48.8584, space=geographic)
print(station)
```

```text
POINT (2.2945 48.8584)
```

## 2. Buffer by 500 meters

On a [geographic CRS](https://gometry.monicz.dev/guide/crs/), [`buffer(500)`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.buffer "buffer")
uses a physical radial distance of 500 meters rather than 500 degrees (on Planar
values, `metric='cartesian'` selects coordinate-plane distance instead):

```python
service_area = station.buffer(500)
print("service area m²:", round(service_area.area))
```

```text
service area m²: 783767
```

## 3. Load GeoJSON features

[`gm.from_geojson(...)`](https://gometry.monicz.dev/api/io/#gometry.from_geojson "from_geojson") parses a GeoJSON
FeatureCollection into an immutable [`Features`](https://gometry.monicz.dev/api/features/#gometry.Features "Features") snapshot with
aligned geometries and properties, then [`with_space`](https://gometry.monicz.dev/api/geometry-array/#gometry.GeometryArray.with_space "with_space")
assigns the Chart model without moving coordinates:

```python
payload = '''
{"type":"FeatureCollection","features":[
  {"type":"Feature","id":"champ-edge","properties":{"name":"Champ-de-Mars edge"},
   "geometry":{"type":"Polygon","coordinates":[[[2.290,48.855],[2.296,48.855],[2.296,48.858],[2.290,48.858],[2.290,48.855]]]}},
  {"type":"Feature","id":"trocadero-side","properties":{"name":"Trocadero side"},
   "geometry":{"type":"Polygon","coordinates":[[[2.287,48.860],[2.293,48.860],[2.293,48.864],[2.287,48.864],[2.287,48.860]]]}},
  {"type":"Feature","id":"out-of-range","properties":{"name":"Out-of-range block"},
   "geometry":{"type":"Polygon","coordinates":[[[2.305,48.865],[2.311,48.865],[2.311,48.870],[2.305,48.870],[2.305,48.865]]]}}
]}
'''
geojson_space = gm.Space(crs=4326, model="planar")
features = gm.from_geojson(payload, space=geojson_space)
blocks = features.geometries.with_space(geographic)
properties = features.properties
names = [row["name"] for row in properties]
print(len(blocks), "blocks loaded:", names)
```

```text
3 blocks loaded: ['Champ-de-Mars edge', 'Trocadero side', 'Out-of-range block']
```

The station, its 500 m service area, and the three blocks.

A station anchors a 500 m service area drawn over three nearby polygon blocks.

- input
- query
- anchor

## 4. Query with `SpatialIndex`

Build a [`SpatialIndex`](https://gometry.monicz.dev/api/spatial-index/#gometry.SpatialIndex "SpatialIndex") over the blocks and query with
`predicate='intersects'`. [`query`](https://gometry.monicz.dev/api/spatial-index/#gometry.SpatialIndex.query "query") runs a
bounding-box prefilter followed by exact refinement (use
[`candidates`](https://gometry.monicz.dev/api/spatial-index/#gometry.SpatialIndex.candidates "candidates") for prefilter row indices only):

```python
idx = gm.SpatialIndex(blocks)
reachable = idx.query(service_area, predicate="intersects")
print("rows intersecting:", reachable.tolist(), "| matched:", [names[i] for i in reachable])
```

```text
rows intersecting: [0, 1] | matched: ['Champ-de-Mars edge', 'Trocadero side']
```

Two blocks intersect the service area; the third is out of range.

The query returns the two intersecting blocks and excludes the out-of-range block.

- query
- result
- excluded
- anchor

## 5. Cover the service area with H3 cells

[`gm.h3_cover`](https://gometry.monicz.dev/api/h3/#gometry.h3_cover "h3_cover") returns H3 candidate keys for joining or
binning; exact membership still uses the source geometry with
[`gm.covers`](https://gometry.monicz.dev/api/predicates/#gometry.covers "covers"):

```python
cells = gm.h3_cover(service_area, resolution=10)
print("H3 cells:", len(cells), "| source covers station:", gm.covers(service_area, station))
```

```text
H3 cells: 76 | source covers station: True
```

H3 cells cover the service area; the geometry still decides membership.

H3 cells extend past the source service area, so exact membership uses the source geometry.

- candidates
- input
- anchor

Next: read [The mental model](https://gometry.monicz.dev/mental-model/), browse the
[User guide](https://gometry.monicz.dev/guide/) (including [Curves & surfaces](https://gometry.monicz.dev/guide/curves/) and
[PostgreSQL & PostGIS](https://gometry.monicz.dev/ecosystem/postgis/)), or look up symbols in the
[API reference](https://gometry.monicz.dev/api/).
