pyspark.sql.functions.st_setsrid#
- pyspark.sql.functions.st_setsrid(geo, srid)[source]#
Returns a new GEOGRAPHY or GEOMETRY value whose SRID is the specified SRID value.
New in version 4.1.0.
- Parameters
Examples
Example 1: Setting the SRID on GEOGRAPHY with SRID from another column. >>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(bytes.fromhex(‘0101000000000000000000F03F0000000000000040’), 4326)], [‘wkb’, ‘srid’]) # noqa >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geogfromwkb(‘wkb’), ‘srid’))).collect() [Row(st_srid(st_setsrid(st_geogfromwkb(wkb), srid))=4326)]
Example 2: Setting the SRID on GEOMETRY with SRID as an integer literal. >>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(bytes.fromhex(‘0101000000000000000000F03F0000000000000040’),)], [‘wkb’]) # noqa >>> df.select(sf.st_srid(sf.st_setsrid(sf.st_geomfromwkb(‘wkb’), 4326))).collect() [Row(st_srid(st_setsrid(st_geomfromwkb(wkb), 4326))=4326)]