ST_ASGEOJSON()
All functions > GEOSPATIAL > ST_ASGEOJSON()
Returns the GeoJSON representation of a geometry or geography.
Signatures
To GeoJSON
Returns: GeoJSON string
ST_ASGEOJSON(geo: T) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
geo | T | Yes | Geometry or geography value |
With:
T: Custom types: GEOM_POINT | GEOM_LINESTRING | GEOM_POLYGON | GEOM_MULTIPOINT | GEOM_MULTILINESTRING | GEOM_MULTIPOLYGON | GEOM_MULTIANY | GEOG_POINT | GEOG_LINESTRING | GEOG_POLYGON | GEOG_MULTIPOINT | GEOG_MULTILINESTRING | GEOG_MULTIPOLYGON | GEOG_MULTIANY
Signature notes:
- Accepts any sub kind
- Works on both GEOMETRY and GEOGRAPHY values
- Not supported on Trino
- Returns NULL if the input is NULL
Examples
FeatureQL
SELECT
f1 := ST_ASGEOJSON(ST_GEOMPOINT(1.0, 2.0)) -- Point to GeoJSON
;Result
| f1 VARCHAR |
|---|
| {"type":"Point","coordinates":[1.0,2.0]} |
On this page