pyspark.sql.functions.st_asbinary#
- pyspark.sql.functions.st_asbinary(geo)[source]#
Returns the input GEOGRAPHY or GEOMETRY value in WKB format.
New in version 4.1.0.
- Parameters
- geo
Columnor str A geospatial value, either a GEOGRAPHY or a GEOMETRY.
- geo
Examples
Example 1: Getting WKB from GEOGRAPHY. >>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(bytes.fromhex(‘0101000000000000000000F03F0000000000000040’),)], [‘wkb’]) # noqa >>> df.select(sf.hex(sf.st_asbinary(sf.st_geogfromwkb(‘wkb’)))).collect() [Row(hex(st_asbinary(st_geogfromwkb(wkb)))=’0101000000000000000000F03F0000000000000040’)]
Example 2: Getting WKB from GEOMETRY. >>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(bytes.fromhex(‘0101000000000000000000F03F0000000000000040’),)], [‘wkb’]) # noqa >>> df.select(sf.hex(sf.st_asbinary(sf.st_geomfromwkb(‘wkb’)))).collect() [Row(hex(st_asbinary(st_geomfromwkb(wkb)))=’0101000000000000000000F03F0000000000000040’)]