Skip to main content

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. Use logging level to suppress warnings.

import logging

logging.getLogger().setLevel(logging.ERROR)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geojson_doctor-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geojson_doctor-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file geojson_doctor-0.1.0.tar.gz.

File metadata

  • Download URL: geojson_doctor-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for geojson_doctor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fa489b47da2d5f90446316fab71de1f2ef3e15d24d858f7c8a550b1a5181373b
MD5 226f0c5573910dc1e94558b07835e68b
BLAKE2b-256 b21839bc1a68e70b434a82d64613c885aa4a726db178b0af72b7b556decf3d95

See more details on using hashes here.

File details

Details for the file geojson_doctor-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: geojson_doctor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for geojson_doctor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4063e211b5352787dbf8d5478916f2dd9da7a78c1ed76a805556bd11b3fca9b
MD5 f2009a907d130713017d050b6df796f5
BLAKE2b-256 d222ce768fffb13757e86eb6114060d5b579f16cfe2bda271fa86e2a894fb423

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page