Skip to main content

Geography

A class to represent a Geography value in Python.

Syntax

Python
from pyspark.databricks.sql.types import Geography

Geography(wkb=<wkb>, srid=<srid>)

Parameters

Parameter

Type

Description

wkb

bytes

The bytes representing the WKB of Geography

srid

integer

The integer value representing SRID of Geography

Methods

Method

Description

getBytes()

Returns the WKB of Geography

getSrid()

Returns the SRID of Geography

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([{'geogwkt': 'POINT(17 7)'}])
g = df.select(dbf.st_geogfromwkt(df.geogwkt).alias("geog")).head().geog
g.getBytes().hex()
Output
'010100000000000000000031400000000000001c40'
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([{'geogwkt': 'POINT(17 7)'}])
g = df.select(dbf.st_geogfromwkt(df.geogwkt).alias("geog")).head().geog
g.getSrid()
Output
4326