snowflake.snowpark.functions.to_geometry¶
- snowflake.snowpark.functions.to_geometry(e: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L3597-L3617)¶
Parses an input and returns a value of type GEOMETRY. Supported inputs are strings in
WKT (well-known text).
WKB (well-known binary) in hexadecimal format (without a leading 0x).
EWKT (extended well-known text).
EWKB (extended well-known binary) in hexadecimal format (without a leading 0x).
GeoJSON.
format.
- Example::
>>> df = session.create_dataframe(['POINT(-122.35 37.55)', 'POINT(20.92 43.33)'], schema=['a']) >>> df.select(to_geometry(col("a"))).collect(statement_params={"GEOMETRY_OUTPUT_FORMAT": "WKT"}) [Row(TO_GEOMETRY("A")='POINT(-122.35 37.55)'), Row(TO_GEOMETRY("A")='POINT(20.92 43.33)')]
Besides strings, binary representation in WKB and EWKB format can be parsed, or objects adhering to GeoJSON format. For all supported formats confer https://docs.snowflake.cn/en/sql-reference/data-types-geospatial#supported-geospatial-object-types.