All Products
Search
Document Center

PolarDB:ST_GeomFromGeoJSON

Last Updated:Mar 28, 2026

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

ParameterDescription
geomjsonThe GeoJSON string to parse. Accepts text, json, or jsonb input.

Usage notes

  • Accepts only GeoJSON geometry fragments (objects with a type and coordinates field). 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)