Share via


st_asgeojson function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 17.1 and above

Important

This feature is in Public Preview.

Note

This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.

Returns the input GEOGRAPHY or GEOMETRY value in GeoJSON format.

Syntax

st_asgeojson ( geoExpr )

Arguments

  • geoExpr: A GEOGRAPHY or GEOMETRY value.

Returns

A value of type STRING. The returned value is the GeoJSON description of the input GEOGRAPHY or GEOMETRY value.

The function returns NULL if the input is NULL.

Examples

-- Export a 3DZ Cartesian point, given in WKT format, in GeoJSON format.
> SELECT st_asgeojson(to_geometry('POINT Z (2.718281828 3.141592653 100)'));
  {"type":"Point","coordinates":[2.718281828,3.141592653,100]}

-- Export a 3DZ geographic point, given in WKT format, in GeoJSON format.
> SELECT st_asgeojson(to_geography('POINT Z (2.718281828 3.141592653 100)'));
  {"type":"Point","coordinates":[2.718281828,3.141592653,100]}