{"id":24311,"library":"pydantic-geojson","title":"Pydantic GeoJSON","description":"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.","status":"active","version":"0.3.2","language":"python","source_language":"en","source_url":"https://github.com/gb-libs/pydantic-geojson","tags":["pydantic","geojson","validation","geo","gis"],"install":[{"cmd":"pip install pydantic-geojson","lang":"bash","label":"default"}],"dependencies":[{"reason":"Core dependency for model validation","package":"pydantic","optional":false}],"imports":[{"note":"Public API is at top-level package","wrong":"from pydantic_geojson.models.geometry import Point","symbol":"Point","correct":"from pydantic_geojson import Point"},{"note":"Public API is at top-level package","wrong":"from pydantic_geojson.models.feature import Feature","symbol":"Feature","correct":"from pydantic_geojson import Feature"},{"note":"Public API is at top-level package","wrong":"from pydantic_geojson.models.feature_collection import FeatureCollection","symbol":"FeatureCollection","correct":"from pydantic_geojson import FeatureCollection"}],"quickstart":{"code":"from pydantic_geojson import Point, Feature, FeatureCollection\n\n# Create a Point\npoint = Point(type='Point', coordinates=[13.405, 52.52])\nprint(point)\n\n# Create a Feature\nfeature = Feature(type='Feature', geometry=point, properties={'name': 'Berlin'})\nprint(feature)\n\n# Create a FeatureCollection\ncollection = FeatureCollection(type='FeatureCollection', features=[feature])\nprint(collection.model_dump_json(indent=2))","lang":"python","description":"Basic usage creating a Point, Feature, and FeatureCollection."},"warnings":[{"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.","message":"Do not include 'type' fields manually for geometry sub-models; they are automatically set by Pydantic validators.","severity":"gotcha","affected_versions":"all"},{"fix":"If your code previously included extraneous fields in Feature/FeatureCollection dicts, remove them before validation or ensure they are not passed.","message":"Version 0.3.0 introduced strict RFC 7946 compliance: Feature objects reject 'coordinates', 'geometries', and 'features' members. Previously such extra fields were silently ignored.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Always provide coordinates in [lon, lat] order. e.g., Point(coordinates=[13.405, 52.52]) for Berlin.","message":"Coordinates for Point must be [longitude, latitude] order (GeoJSON spec), not [latitude, longitude].","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure coordinates is a list of numbers: Point(coordinates=[0, 0])","cause":"Passing a string instead of a list for coordinates.","error":"pydantic_core._pydantic_core.ValidationError: 1 validation error for Point\ncoordinates\n  Input should be a valid list [type=list_type, input_value='...', input_type=str]"},{"fix":"Set type='Feature' when creating a Feature, or let the model default (if any) handle it.","cause":"The 'type' field must be exactly 'Feature' for Feature objects.","error":"pydantic_core._pydantic_core.ValidationError: 1 validation error for Feature\ntype\n  Input should be 'Feature' [type=literal_error, input_value='...', input_type=str]"},{"fix":"Use from pydantic_geojson import Point, Feature, etc. Instead of from pydantic_geojson.models.geometry import Point.","cause":"Trying to import from internal submodules instead of public top-level package.","error":"ModuleNotFoundError: No module named 'pydantic_geojson.models'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}