Provides Pydantic models for validating GeoJSON objects (Point, LineString, Polygon, Feature, FeatureCollection, etc.) with strict adherence to RFC 7946. Current version 0.3.2, requires Python >=3.9, release cadence irregular.
pip install pydantic-geojsonVerified import paths — ran on the pinned version, not inferred.
Basic usage creating a Point, Feature, and FeatureCollection.
Omit 'type' when instantiating model classes like Point, LineString, etc. For example: Point(coordinates=[0, 0]) is valid; Point(type='Point', coordinates=[0, 0]) also works but is redundant.
If your code previously included extraneous fields in Feature/FeatureCollection dicts, remove them before validation or ensure they are not passed.
Always provide coordinates in [lon, lat] order. e.g., Point(coordinates=[13.405, 52.52]) for Berlin.