Constructs a geometry object from a GeoJSON string.
Syntax
geometry ST_GeomFromGeoJSON(text geomjson);
geometry ST_GeomFromGeoJSON(json geomjson);
geometry ST_GeomFromGeoJSON(jsonb geomjson);Parameters
| Parameter | Description |
|---|---|
geomjson | The GeoJSON string to parse. Accepts text, json, or jsonb input. |
Usage notes
Accepts only GeoJSON geometry fragments (objects with a
typeandcoordinatesfield). Passing a complete GeoJSON document returns an error.Preserves the z-coordinate of 3D geometries.
Examples
SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[116,40]}'));
st_astext
---------------
POINT(116 40)
(1 row)