Python library for validating GeoJSON plot geometries in agricultural supply chains.
Part of the DIASCA data exchange toolkit.
This library validates GeoJSON files to ensure plot geometries are correctly formatted and compliant with spatial standards required for:
- EUDR compliance – Validate plot polygons for deforestation-free sourcing
- Traceability – Ensure site geometries meet data quality requirements
- Data exchange – Validate GeoJSON before import/export
cd tools/geojson-validator
poetry installfrom src.geojson_validator import GeoJsonValidator
# From a dictionary
validator = GeoJsonValidator({"type": "Point", "coordinates": [0, 0]})
# From a file
validator = GeoJsonValidator.from_filepath("path/to/plot.geojson")
# From a string
validator = GeoJsonValidator.from_string('{"type": "Polygon", ...}')
# Check validity
if validator.is_valid():
print("Valid GeoJSON!")poetry run pytest# Install dependencies
poetry install
# Install pre-commit hooks
poetry run pre-commit install# Run linting and formatting
poetry run pre-commit run --all-files
# Run tests
poetry run pytest# Production dependency
poetry add package_name
# Development dependency
poetry add --group dev package_name| Method | Description |
|---|---|
__init__(geojson_obj) |
Initialize with a GeoJSON dict |
from_string(geojson_str) |
Create from a JSON string |
from_filepath(filepath) |
Create from a file path |
validate() |
Validate the GeoJSON structure |
is_valid() |
Returns True if valid, False otherwise |
MIT License – See LICENSE
Part of the DIASCA project, maintained by COSA