Source: https://gometry.monicz.dev/guide/geographic/

# Geographic topology & antimeridian

Choose Chart [`Space`](https://gometry.monicz.dev/api/crs/#gometry.Space "Space") for straight longitude/latitude edges that
cross the antimeridian on a continuous longitude branch. A geographic CRS
alone does not select Chart: `gm.Space(crs=4326)` is Planar and keeps the
literal X/Y path. Spherical edges follow minor great-circle arcs instead.
The examples below use Chart unless stated otherwise.

## Native angular units and periodic aliases

Geographic frames are read from the CRS rather than assuming WGS 84 degrees:
`EPSG:4326` uses degrees (seam at ±180°, poles at ±90°), `EPSG:4807` uses grads
(seam at ±200, poles at ±100, Paris prime meridian), and radian CRSs use ±π /
±π/2. In Chart Space, adding a period to a longitude gives the same location:

```python
import math
import gometry as gm

radian_crs = (
    'GEOGCS["WGS 84 radians",DATUM["WGS_1984",'
    'SPHEROID["WGS 84",6378137,298.257223563]],'
    'PRIMEM["Greenwich",0],UNIT["radian",1],'
    'AXIS["Longitude",EAST],AXIS["Latitude",NORTH]]'
)
for name, crs, period in (("degree", 4326, 360.0), ("grad", 4807, 400.0), ("radian", radian_crs, math.tau)):
    origin = gm.Point(0.0, 0.0, space=gm.Space(crs=crs, model="chart"))
    alias = gm.Point(period, 0.0, space=gm.Space(crs=crs, model="chart"))
    print(f"{name}: one-turn distance = {gm.distance(origin, alias)} m")
```

```text
degree: one-turn distance = 0.0 m
grad: one-turn distance = 0.0 m
radian: one-turn distance = 0.0 m
```

Always supply coordinates in the CRS's native angular units; gometry handles
unit and prime-meridian conversion automatically.

## Polar rings and full-turn edges

In Chart Space, `(0, 20)` and `(360, 20)` in EPSG:4326 denote the same
point, just as `(-180, 20)` and `(180, 20)` do. An edge between either
pair has zero length. To draw a full parallel, supply intermediate vertices
that trace the intended route.

A Chart ring can cross the equator and still enclose a pole. Its traversal
selects the interior; neither the latitude range nor a closing longitude
spelling selects it. Reversing the input coordinates when constructing a
polygon selects the other side. Calling `polygon.reverse()` instead retains
the represented region.

```python
import gometry as gm

chart = gm.Space(crs=4326, model="chart")
ring = [(0, -10), (120, 0), (240, 10)]
north = gm.Point(0, 89, space=chart)
south = gm.Point(0, -89, space=chart)
for boundary in (ring, ring[::-1]):
    region = gm.Polygon(boundary, space=chart)
    print("north, south:", gm.contains(region, north), gm.contains(region, south))
```

```text
north, south: True False
north, south: False True
```

## Crossing the antimeridian

When a Chart geometry's longitude interval crosses the seam, its
[`bounds`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.bounds "bounds property") report `west > east`. Pass those bounds
and the same Space to [`gm.box`](https://gometry.monicz.dev/api/constructors/#gometry.box "box") or [`gm.boxes`](https://gometry.monicz.dev/api/constructors/#gometry.boxes "boxes") to
build a seam-crossing Chart rectangle. A Planar box with that ordering is
invalid even in EPSG:4326.

For an operation that needs coordinate-plane input, convert the represented
line to Planar Space with [`to_space`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.to_space "to_space"). Declaring
a new Space with `with_space` would keep the raw coordinates and change the
path instead. [Geographic buffers and offsets](https://gometry.monicz.dev/guide/constructive/#geographic-buffers-and-offsets)
can operate directly in the source Space.

input crossing ±180°

input crossing ±180°

- lon/lat world frame
- query

to\_space(planar)

to\_space(planar)

- lon/lat world frame
- result

```python
import gometry as gm

chart = gm.Space(crs=4326, model="chart")
planar = gm.Space(crs=4326, model="planar")
region = gm.box(170, -10, -170, 10, space=chart)
track = gm.LineString([(179, 10), (-179, 10)], space=chart)
probes = gm.points([179.5, -179.5, 0.0], [0.0, 0.0, 0.0], space=chart)

matches = gm.SpatialIndex(gm.GeometryArray([region])).query(probes, predicate="within")
print("region:", region.geometry_type, region.bounds)
print("track crosses:", track.crosses_antimeridian, "→", track.to_space(planar).geometry_type)
print("point matches:", matches.values.tolist())
```

```text
region: MultiPolygon (170.0, -10.0, -170.0, 10.0)
track crosses: True → MultiLineString
point matches: [0, 0]
```

[`SpatialIndex`](https://gometry.monicz.dev/api/spatial-index/#gometry.SpatialIndex "SpatialIndex") widens periodic crossing envelopes during
candidate search and removes middle-of-map false positives during exact
predicate refinement. Chart `simplify` rejects any vertex removal that
would turn a non-crossing edge into a seam-crossing edge. Geographic
[`triangulate`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.triangulate "triangulate") (`delaunay`, `constrained`) and
[`voronoi`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.voronoi "voronoi") handle seam crossings directly; see
[Tessellation](https://gometry.monicz.dev/guide/constructive/#tessellation-triangulate-voronoi-polygonize).

## Seam cuts, overlays, and polygon boundaries

At the seam meridian, shared spans with polygon interiors on opposite sides are
treated as chart cuts regardless of whether rings spell them on the east or west
side — they do not count as self-intersections or boundary edges, and they
cancel out of geographic polygon perimeter. Same-side overlaps remain invalid.

[`Polygon.boundary`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.boundary "boundary") and
[`MultiPolygon.boundary`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.boundary "boundary") return the topological
boundary of the occupied region: internal shared edges, antimeridian chart cuts,
and polar-cap closure edges are omitted, while genuine one-sided edges on the
seam remain:

```python
import gometry as gm

crossing = gm.Polygon([(170, 40), (190, 40), (190, 50), (170, 50)], space=gm.Space(crs=4326, model="chart"))
print(crossing.boundary().to_wkt())
```

```text
LINESTRING (170 40, 170 50, -180 50, -170 50, -170 40, -180 40, 170 40)
```

Chart overlays insert seam splits along straight edges in the unwrapped
chart (interpolating eligible Z/M by ellipsoidal arclength along the original
source edge), preserve polar closures only over the pole selected by the region,
and verify binary64 coordinate rounding for constructed nodes without moving
stored input vertices or placing nodes onto a seam or pole. If no
topology-preserving binary64 assignment fits (or the bounded work budget is
exhausted), the overlay raises
[`RepresentabilityError`](https://gometry.monicz.dev/api/errors/#gometry.RepresentabilityError "RepresentabilityError") or
[`ResourceLimitError`](https://gometry.monicz.dev/api/errors/#gometry.ResourceLimitError "ResourceLimitError") rather than returning altered
topology.

## Numerical domain summary

Geodesic measurements require a supported ellipsoid (`|f| <= 0.02`).
Geographic `dwithin` raises [`CRSError`](https://gometry.monicz.dev/api/errors/#gometry.CRSError "CRSError") if its search cannot
resolve the requested radius; it does not widen the radius to break a tie.
See [geographic numerical accuracy](https://gometry.monicz.dev/guide/crs/#geographic-numerical-accuracy) for
the ellipsoid limits, point-to-edge search budget, and Hausdorff error target.
