A toolset for validating, repairing, and transforming GeoJSON data.
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geojson_doctor-0.1.1.tar.gz.
File metadata
- Download URL: geojson_doctor-0.1.1.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47022bdc07247a1d225f01652405a1790039cf9247753156cce5bf590ff95771
|
|
| MD5 |
c0908f0c90fc7ea3f36c7efa94456c15
|
|
| BLAKE2b-256 |
8abcb07ce7c7c101c63e3dda8fbde8c8db36781db7fa2c074660cb7abff3c2ca
|
File details
Details for the file geojson_doctor-0.1.1-py3-none-any.whl.
File metadata
- Download URL: geojson_doctor-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0d9527d591ea4d12578fe348deacd616b6e787d9f28ec29f120cae8f64e2e7a
|
|
| MD5 |
93cf5a50d49ec253438ca00e6bd5a778
|
|
| BLAKE2b-256 |
4ec956bc6c29bd4cd8e189b362abecd772eaee5bec992dd2dc348b8de1aebd6d
|