PostGISGeometry Input

ST_GeomFromGeoJSON

What is ST_GeomFromGeoJSON?

ST_GeomFromGeoJSON parses a GeoJSON geometry object and returns the corresponding PostGIS geometry. Accepts text, jsonb, or json input.

SQL
1ST_GeomFromGeoJSON(text geojson)geometry
2ST_GeomFromGeoJSON(jsonb geojson)geometry
3ST_GeomFromGeoJSON(json geojson)geometry

Per RFC 7946, GeoJSON coordinates are always in WGS84 longitude/latitude, so the result is always SRID 4326 (unless a non-standard CRS member is present).

When would you use ST_GeomFromGeoJSON?

Use ST_GeomFromGeoJSON when ingesting data from modern web services, REST APIs, OpenStreetMap Overpass queries, or Python/JavaScript toolchains that emit GeoJSON by default. It is the de facto standard for web-era spatial data exchange.

For columnar ingest where the source is a jsonb field containing embedded geometry, the jsonb overload skips the text intermediary.

FAQs

What SRID does the output have?

EPSG:4326 per RFC 7946. Non-standard crs members are parsed for backward compatibility with GeoJSON 2008, but RFC 7946 disallows them.

Does it handle Feature and FeatureCollection wrappers?

No — it accepts only a GeoJSON geometry object. Extract the geometry field first if the input is a Feature.

Is it slower than ST_GeomFromText?

Slightly. JSON parsing is a bit more expensive than WKT. For bulk loads, pre-convert to EWKB.

Can it parse non-standard types?

No. Only the seven GeoJSON types (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection) are supported.