Antimeridian

raw JSON →
0.4.7 verified Mon Apr 27 auth: no python

Corrects GeoJSON geometries (Polygons, MultiPolygons, etc.) that cross the 180th meridian (antimeridian). Splits them into valid, non-wrapping geometries. Current version: 0.4.7. Release cadence: infrequent, as needed.

pip install antimeridian
error ValueError: Expected a GeoJSON geometry object, got list
cause Passed a list of coordinates instead of a geometry dict.
fix
Wrap coordinates in a valid GeoJSON structure: {'type': 'Polygon', 'coordinates': your_list}
error antimeridian.InvalidGeometryError: Geometry type not supported: LineString
cause Attempted to fix a non-polygonal geometry type that antimeridian cannot handle.
fix
Only Polygon, MultiPolygon, and their derivatives (e.g., in a Feature) are supported. For other types, use other libraries or preprocess.
error TypeError: fix_geojson() missing 1 required positional argument: 'geometry'
cause Called fix_geojson without arguments or with incorrect keyword.
fix
Use: fix_geojson(geometry_dict)
gotcha fix_geojson returns a new dictionary; it does not modify the input in place. Do not assume mutation.
fix Always assign the result: fixed = fix_geojson(original)
gotcha The function may raise InvalidGeometryError if the input is not a valid GeoJSON geometry object (e.g., missing 'type' or 'coordinates').
fix Validate your GeoJSON structure before passing it. Wrap in try/except if needed.
breaking Version 0.4.0 changed the internal splitting algorithm, which may produce different output shapes for edge cases (e.g., geometries that touch the antimeridian).
fix Test your specific geometries after upgrading. Old behavior can't be restored.

Correct a simple polygon crossing the antimeridian (180° longitude).

from antimeridian import fix_geojson
import json

geojson = {
    "type": "Polygon",
    "coordinates": [[
        [179.0, -10.0],
        [-179.0, -10.0],
        [-179.0, 10.0],
        [179.0, 10.0],
        [179.0, -10.0]
    ]]
}

# Fix the geometry
fixed = fix_geojson(geojson)
print(json.dumps(fixed, indent=2))