snowflake.snowpark.functions.st_geometryfromwkb

snowflake.snowpark.functions.st_geometryfromwkb(varchar_or_binary_expression: Union[snowflake.snowpark.column.Column, str], srid: Union[snowflake.snowpark.column.Column, str] = None, allow_invalid: Union[snowflake.snowpark.column.Column, str] = None) Column[source]

Parses a WKB (well-known binary) or EWKB (extended well-known binary) representation of a geometry and returns a GEOMETRY object.

Parameters:
  • varchar_or_binary_expression (ColumnOrName) – A VARCHAR or BINARY expression containing the WKB or EWKB representation of a geometry.

  • srid (ColumnOrName, optional) – The SRID (spatial reference system identifier) to use for the geometry. If not specified, the SRID from the EWKB is used, or 0 if the input is WKB.

  • allow_invalid (ColumnOrName, optional) – If TRUE, allows invalid geometries to be processed. If FALSE or not specified, invalid geometries will cause an error.

Returns:

A GEOMETRY object parsed from the WKB/EWKB representation.

Return type:

Column

Examples::
>>> from snowflake.snowpark.functions import col, lit
>>> df = session.create_dataframe([
...     ['010100000066666666A9CB17411F85EBC19E325641'],
...     ['0101000020797F000066666666A9CB17411F85EBC19E325641']
... ], schema=["wkb_data"])
>>> df.select(st_geometryfromwkb(col("wkb_data")).alias("geometry")).collect()
[Row(GEOMETRY='{\n  "coordinates": [\n    3.898663500000000e+05,\n    5.819003030000000e+06\n  ],\n  "type": "Point"\n}'), Row(GEOMETRY='{\n  "coordinates": [\n    3.898663500000000e+05,\n    5.819003030000000e+06\n  ],\n  "type": "Point"\n}')]
Copy
>>> df2 = session.create_dataframe([
...     ['010100000066666666A9CB17411F85EBC19E325641']
... ], schema=["wkb_data"])
>>> df2.select(st_geometryfromwkb(col("wkb_data"), lit(4326)).alias("geometry")).collect()
[Row(GEOMETRY='{\n  "coordinates": [\n    3.898663500000000e+05,\n    5.819003030000000e+06\n  ],\n  "type": "Point"\n}')]
Copy
>>> df3 = session.create_dataframe([
... ['010100000066666666A9CB17411F85EBC19E325641']
... ], schema=["wkb_data"])
>>> df3.select(st_geometryfromwkb(col("wkb_data"), lit(4326), lit(True)).alias("GEOMETRY")).collect()
[Row(GEOMETRY='{\n  "coordinates": [\n    3.898663500000000e+05,\n    5.819003030000000e+06\n  ],\n  "type": "Point"\n}')]
Copy
>>> df3 = session.create_dataframe([
... ['010100000066666666A9CB17411F85EBC19E325641']
... ], schema=["wkb_data"])
>>> df3.select(st_geometryfromwkb(col("wkb_data"),allow_invalid=lit(True)).alias("GEOMETRY")).collect()
[Row(GEOMETRY='{\n  "coordinates": [\n    3.898663500000000e+05,\n    5.819003030000000e+06\n  ],\n  "type": "Point"\n}')]
Copy