Registry / serialization / pydantic-geojson

pydantic-geojson

JSON →
library0.3.2pypypi✓ verified 82d ago

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-geojson
INSTALL
IMPORT
SIG · PYDANTIC-GEOJSON
P
pydantic-geojson
serializationpythonv0.3.2
Install
3.3s avg
Import
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 28MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.3s · import 0.000s · 28MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PointModel
from pydantic_geojson import PointModel
from pydantic_geojson import Point
FeatureModel
from pydantic_geojson import FeatureModel
FeatureCollectionModel
from pydantic_geojson import FeatureCollectionModel

Basic usage creating a Point, Feature, and FeatureCollection.

from pydantic_geojson import Point, Feature, FeatureCollection # Create a Point point = Point(type='Point', coordinates=[13.405, 52.52]) print(point) # Create a Feature feature = Feature(type='Feature', geometry=point, properties={'name': 'Berlin'}) print(feature) # Create a FeatureCollection collection = FeatureCollection(type='FeatureCollection', features=[feature]) print(collection.model_dump_json(indent=2))
Debug
Known issues
gotchaDo not include 'type' fields manually for geometry sub-models; they are automatically set by Pydantic validators.
fix
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.
affects: all
breakingVersion 0.3.0 introduced strict RFC 7946 compliance: Feature objects reject 'coordinates', 'geometries', and 'features' members. Previously such extra fields were silently ignored.
fix
If your code previously included extraneous fields in Feature/FeatureCollection dicts, remove them before validation or ensure they are not passed.
affects: >=0.3.0
gotchaCoordinates for Point must be [longitude, latitude] order (GeoJSON spec), not [latitude, longitude].
fix
Always provide coordinates in [lon, lat] order. e.g., Point(coordinates=[13.405, 52.52]) for Berlin.
affects: all
Upgrade
Version history
0.3.2latest on PyPI · released Mar 1, 2026
Audit
Dependencies
pydanticrequiredCore dependency for model validation
Agent activity
15 hits · last 30 days
node
14
Resources
pydantic-geojson — pip install pydantic-geojson · libregistry