Geojson Doctor
A Python utility library for cleaning, normalizing, and transforming GeoJSON geometries.
Developed at Concordia university in Canada as part of the research group from the Next Generation Cities Institute.
It provides functions to:
- Fix invalid geometries.
- Ensure proper polygon ring orientation.
- Removes redundant vertices.
- Add ID field based on properties
- Reproject geometries between coordinate reference systems (CRS).
- Convert single-polygon MultiPolygons to Polygons.
- Remove interior points from Polygons
Usage
pip install geojson-doctor
Imports
from geojson_doctor import fix
from geojson_doctor.transform import change_crs, multipolygon_to_polygon, remove_interior
from geojson_doctor.utilities import generate_ids
Simple example
with open('data/example.geojson', encoding='utf-8') as f:
data = json.load(f)
data = fix(data)
Full example
with open('data/example.geojson', encoding='utf-8') as f:
data = json.load(f)
data = generate_ids(data, from_property="name")
data = change_crs(data, 'EPSG:32188', 'EPSG:4326')
data = multipolygon_to_polygon(data, method='keep_first')
data = remove_interior(data)
data = fix(data, workflow=['fix_validity'])
Logging
This package uses Python’s built-in logging to provide warnings whenever geometries are modified.
Modifications to geometry are all applied as a warning. While removed geometries are logged as an error. Use logging level to suppress warnings.
import logging
logging.getLogger().setLevel(logging.ERROR)
Release files for geojson-doctor 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| geojson_doctor-0.1.1.tar.gz | 12.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| geojson_doctor-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.8 kB
Release files / geojson_doctor-0.1.1.tar.gz
| Download URL | geojson_doctor-0.1.1.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47022bdc07247a1d225f01652405a1790039cf9247753156cce5bf590ff95771
|
|
BLAKE2b-256 checksum How to use checksums |
8abcb07ce7c7c101c63e3dda8fbde8c8db36781db7fa2c074660cb7abff3c2ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / geojson_doctor-0.1.1-py3-none-any.whl
| Download URL | geojson_doctor-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0d9527d591ea4d12578fe348deacd616b6e787d9f28ec29f120cae8f64e2e7a
|
|
BLAKE2b-256 checksum How to use checksums |
4ec956bc6c29bd4cd8e189b362abecd772eaee5bec992dd2dc348b8de1aebd6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|