Nota
L-aċċess għal din il-paġna jeħtieġ l-awtorizzazzjoni. Tista’ tipprova tidħol jew tibdel id-direttorji.
L-aċċess għal din il-paġna jeħtieġ l-awtorizzazzjoni. Tista’ tipprova tibdel id-direttorji.
Important
This feature is in Public Preview. You can confirm preview enrollment on the Previews page. See Manage Azure Databricks previews.
Parses the input BINARY or string value and returns the corresponding Geometry value. An error is thrown for invalid input.
For the corresponding Databricks SQL function, see to_geometry function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.to_geometry(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
A string value in WKT or GeoJSON format, or a BINARY value in WKB or EWKB format representing a Geometry value. |
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT Z (3 4 5)',)], ['wkt'])
df.select(dbf.st_asewkt(dbf.to_geometry('wkt')).alias('result')).collect()
[Row(result='POINT Z (3 4 5)')]
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('{"type":"MultiPoint","coordinates":[[3,4,5]]}',)], ['geojson'])
df.select(dbf.st_asewkt(dbf.to_geometry('geojson')).alias('result')).collect()
[Row(result='SRID=4326;MULTIPOINT Z ((3 4 5))')]
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(bytes.fromhex('01ef0300000100000001e9030000000000000000084000000000000010400000000000001440'),)], ['wkb'])
df.select(dbf.st_asewkt(dbf.to_geometry('wkb')).alias('result')).collect()
[Row(result='GEOMETRYCOLLECTION Z (POINT Z (3 4 5))')]
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(bytes.fromhex('01020000a0110f000002000000000000000000084000000000000010400000000000001440000000000000084000000000000010400000000000001440'),)], ['ewkb'])
df.select(dbf.st_asewkt(dbf.to_geometry('ewkb')).alias('result')).collect()
[Row(result='SRID=3857;LINESTRING Z (3 4 5,3 4 5)')]