ST_AsGeoJSON

ST_AsGeoJSON takes a geometry column and returns the GeoJSON representation of the geometry as a string column. Geometries that have an m-value and no z-coordinate will only return x,y coordinates.

FunctionSyntax
Pythonas_geojson(geometry)
SQLST_AsGeoJson(geometry)
ScalaasGeojson(geometry)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for as_geojson.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
from geoanalytics_fabric.sql import functions as ST, Point

df = spark.createDataFrame([(Point(-178, -17),)], ["point"])

df.select(ST.as_geojson("point").alias("as_geojson")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+----------------------------------------------------+
|as_geojson                                          |
+----------------------------------------------------+
|{"type":"Point","coordinates":[-178,-17],"crs":null}|
+----------------------------------------------------+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.