snowflake.snowpark.functions.st_asgeojson¶
- snowflake.snowpark.functions.st_asgeojson(geography_or_geometry_expression: Union[snowflake.snowpark.column.Column, str]) Column [source]¶
Returns the GeoJSON representation of a GEOGRAPHY or GEOMETRY object.
- Parameters:
geography_or_geometry_expression (ColumnOrName) – The GEOGRAPHY or GEOMETRY data.
- Returns:
The GeoJSON representation as a string.
- Return type:
Example:
>>> from snowflake.snowpark.functions import col, to_geography >>> df = session.create_dataframe(['POINT(-122.35 37.55)', 'LINESTRING(-124.20 42.00, -120.01 41.99)'], schema=['g']) >>> df = df.select(to_geography(col("g")).alias("geography")) >>> df.select(st_asgeojson(col("geography"))).collect() [Row(ST_ASGEOJSON("GEOGRAPHY")='{\n "coordinates": [\n -122.35,\n 37.55\n ],\n "type": "Point"\n}'), Row(ST_ASGEOJSON("GEOGRAPHY")='{\n "coordinates": [\n [\n -124.2,\n 42\n ],\n [\n -120.01,\n 41.99\n ]\n ],\n "type": "LineString"\n}')]