This topic describes the ST_GeomFromGeoJSON function. This function constructs a geometry object by using 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 that you want to specify. |
Description
- This function supports only GeoJSON geometry fragments. If you use this function on an entire GeoJSON document, this function returns an error.
- This function supports 3D objects and does not discard the z-index of the geometry object that is constructed.
Examples
SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[116,40]}'));
st_astext
---------------
POINT(116 40)
(1 row)