https://github.com/gadomski/antimeridian
Correct GeoJSON geometries that cross the 180th meridian
https://github.com/gadomski/antimeridian
antimeridian geojson geospatial python
Last synced: over 1 year ago
JSON representation
Correct GeoJSON geometries that cross the 180th meridian
- Host: GitHub
- URL: https://github.com/gadomski/antimeridian
- Owner: gadomski
- License: apache-2.0
- Created: 2023-04-11T23:36:09.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-08T20:22:41.000Z (over 1 year ago)
- Last Synced: 2025-03-28T14:09:46.830Z (over 1 year ago)
- Topics: antimeridian, geojson, geospatial, python
- Language: Python
- Homepage: https://www.gadom.ski/antimeridian/
- Size: 24.8 MB
- Stars: 74
- Watchers: 5
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# antimeridian
[](https://github.com/gadomski/antimeridian/actions/workflows/ci.yaml)
[](https://www.gadom.ski/antimeridian/)
[](https://pypi.org/project/antimeridian/)
[](https://anaconda.org/conda-forge/antimeridian)
[](https://github.com/gadomski/antimeridian/blob/main/LICENSE)
[](https://github.com/gadomski/antimeridian/blob/main/CODE_OF_CONDUCT)
[](https://joss.theoj.org/papers/2a6c626b3774c8310e46c05fdf8d10de)
[](https://doi.org/10.5281/zenodo.14335984)

Fix shapes that cross the antimeridian.
See [the documentation](https://antimeridian.readthedocs.io) for information about the underlying algorithm.
Depends on [shapely](https://shapely.readthedocs.io) and [numpy](https://numpy.org/).
Can fix:
- Shapely [`Polygon`](https://shapely.readthedocs.io/en/stable/reference/shapely.Polygon.html#shapely.Polygon), [`MultiPolygon`](https://shapely.readthedocs.io/en/stable/reference/shapely.MultiPolygon.html#shapely.MultiPolygon), [`LineString`](https://shapely.readthedocs.io/en/stable/reference/shapely.LineString.html#shapely.LineString), and [`MultiLineString`](https://shapely.readthedocs.io/en/stable/reference/shapely.MultiLineString.html#shapely.MultiLineString) objects
- GeoJSON [Polygons](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6), [MultiPolygons](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.7), [Features](https://datatracker.ietf.org/doc/html/rfc7946#section-3.2) and [FeatureCollections](https://datatracker.ietf.org/doc/html/rfc7946#section-3.3), as dictionaries
- Anything that has a [`__geo_interface__`](https://gist.github.com/sgillies/2217756)
## Usage
```shell
python -m pip install antimeridian
```
Then:
```python
import antimeridian
fixed = antimeridian.fix_geojson(geojson)
```
We also have some utilities to create [bounding boxes](https://antimeridian.readthedocs.io/en/latest/api.html#antimeridian.bbox) and [centroids](https://antimeridian.readthedocs.io/en/latest/api.html#antimeridian.centroid) from antimeridian-crossing polygons and multipolygons.
See [the documentation](https://www.gadom.ski/antimeridian/) for a complete API reference.
### Command line interface
Use the `cli` optional dependency to install the `antimeridian` CLI:
```shell
python -m pip install 'antimeridian[cli]'
antimeridian fix input.json > output.json
```
## Developing
Get [uv](https://docs.astral.sh/uv/getting-started/installation/).
Then:
```shell
git clone https://github.com/gadomski/antimeridian
cd antimeridian
uv sync
```
We use [pytest](https://docs.pytest.org) for tests:
```shell
uv run pytest
```
To build and serve the docs locally:
```shell
uv run mkdocs serve
```
## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md).
## License
[Apache-2.0](https://github.com/gadomski/antimeridian/blob/main/LICENSE)