Pular para o conteúdo principal

para_geografia

info

Visualização

Este recurso está em Pré-visualização Pública.

Analisa o valor de entrada BINÁRIO ou em formato de string e retorna o valor Geográfico correspondente. Ocorreu um erro devido à entrada inválida.

Para a função Databricks SQL correspondente, consulte a funçãoto_geography.

Sintaxe

Python
from pyspark.databricks.sql import functions as dbf

dbf.to_geography(col=<col>)

Parâmetros

Parâmetro

Tipo

Descrição

col

pyspark.sql.Column ou str

Um valor de string no formato WKT ou GeoJSON, ou um valor BINÁRIO no formato WKB representando um valor geográfico .

Exemplos

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT Z (3 4 5)',)], ['wkt'])
df.select(dbf.st_asewkt(dbf.to_geography('wkt')).alias('result')).collect()
Output
[Row(result='SRID=4326;POINT Z (3 4 5)')]
Python
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_geography('geojson')).alias('result')).collect()
Output
[Row(result='SRID=4326;MULTIPOINT Z ((3 4 5))')]
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(bytes.fromhex('01ef0300000100000001e9030000000000000000084000000000000010400000000000001440'),)], ['wkb'])
df.select(dbf.st_asewkt(dbf.to_geography('wkb')).alias('result')).collect()
Output
[Row(result='SRID=4326;GEOMETRYCOLLECTION Z (POINT Z (3 4 5))')]