Skip to content

The mental model

Every geometry carries a complete Space: its coordinate reference system, optional coordinate epoch, and curve model (planar, chart, or spherical). The curve model defines the path between stored vertices; the measurement metric decides how that path is measured. Changing the metric never changes the curve.

Declare, transform, refine

Three rules govern every pipeline:

  1. Declare with with_space — attaches or replaces the complete Space without moving numeric coordinates.
  2. Transform with to_space — converts the represented shape into another target Space (reprojecting through PROJ and/or converting curve models).
  3. Refine spatial candidates — a SpatialIndex.candidates bbox lookup or a grid cover narrows the search; it is not an exact geometry answer. Keep the source geometry and refine candidates with an exact predicate (SpatialIndex.query, gm.covers, gm.intersects).

See CRS, units & measurement, Candidates vs query, and Exact membership with the source geometry.

Curve models, metrics, and candidates

gometry separates curve interpretation, measurement, and discrete grid keys instead of conflating them:

  • Curve model (Space.model) — chooses what each edge represents:
  • 'planar' — straight segments (and ISO SQL/MM curves & surfaces) in literal X/Y coordinates; matches PostGIS geometry.
  • 'chart' — straight longitude/latitude segments in a geographic CRS with periodic longitude, antimeridian seam, and polar-ring handling. See Geographic topology & antimeridian.
  • 'spherical' — minor great-circle arcs evaluated on the sphere without a longitude seam (backed by S2); matches PostGIS geography.
  • Measurement metric — on a geographic CRS, the default measuring surface is the CRS ellipsoid: length and distance are in meters, area in square meters. An explicit Sphere selects a sphere instead. Projected CRSs use native linear units (with optional unit='meters'), unreferenced geometries use raw coordinate units, and metric='cartesian' measures planar coordinates directly. See CRS, units & measurement.
  • Discrete grid keys — H3, S2, geohash, and XYZ tiles assign typed CellArray keys for grouping, joins, and prefiltering. Cell covers return candidates that should be refined with exact predicates against the source geometry. See Grids & geocodes.
1. Ellipsoidal measurement (245 km², 17.8 km)
Ellipsoidal measurement evaluates area on the source chart region and geodesic distance between two anchor points.
  • source region
  • measured / exact result
  • geodesic endpoints
2. Chart topology (intersection)
Chart topology intersects the source region and query window to produce the overlapping polygon.
  • source region
  • query window
  • measured / exact result
3. Discrete grid keys (418 H3 cells)
Discrete grid keys cover the source region with candidate H3 cells that extend past its edges and require predicate refinement.
  • grid candidates
  • source region

One geographic region viewed through gometry’s spatial layers: ellipsoidal measurement, topology, and discrete grid keys.

For naming rules, Python protocols, equality, and error types, see API conventions.