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 | A GeoJSON geometry fragment of type text, json, or jsonb. |
Usage notes
Pass a GeoJSON geometry fragment, not a complete GeoJSON document. Passing a full document returns an error.
3D geometries are fully supported. The Z coordinate is preserved in the constructed geometry object.
Examples
2D point
SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[116,40]}'));Output:
st_astext
---------------
POINT(116 40)
(1 row)