Constructs a geometry object from a GeoJSON geometry fragment.
Syntax
geometry ST_GeomFromGeoJSON(text geomjson);
geometry ST_GeomFromGeoJSON(json geomjson);
geometry ST_GeomFromGeoJSON(jsonb geomjson);Parameters
| Parameter | Type | Description |
|---|---|---|
geomjson | text, json, or jsonb | The GeoJSON geometry fragment to parse. |
Usage notes
Pass a GeoJSON geometry fragment (for example,
{"type":"Point","coordinates":[...]}), not a complete GeoJSON Feature or FeatureCollection document. Passing a full GeoJSON document returns an error.3D geometries are fully supported. The z-coordinate is preserved in the returned geometry object.
Examples
2D point
SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[116,40]}')); st_astext
---------------
POINT(116 40)
(1 row)该文章对您有帮助吗?