Skip to main content

st_estimatesrid

Applies to: check marked yes Databricks Runtime 18.1 and above

Preview

This feature is in Public Preview.

Returns the best projected spatial reference identifier (SRID) for the center of the bounding box of the input Geometry value. The returned SRID value represents either a Universal Transverse Mercator (UTM) projected coordinate system or a Universal Polar Stereographic (UPS) projected coordinate system.

If the geometry is empty, the function returns None.

For the corresponding Databricks SQL function, see st_estimatesrid function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.st_estimatesrid(col=<col>)

Parameters

Parameter

Type

Description

col

pyspark.sql.Column or str

A Geometry value with coordinates in degrees in the range [-180, 180] for longitudes and [-90, 90] for latitudes.

Examples

Return UTM zone 10N SRID for a point in San Francisco.

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('POINT(-122.419 37.775)',)], ['wkt'])
df.select(dbf.st_estimatesrid(dbf.st_geomfromtext('wkt')).alias('result')).collect()
Output
[Row(result=32610)]

Return UTM zone 31N SRID for a polygon near the Prime Meridian:

Python
df = spark.createDataFrame([('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))',)], ['wkt'])
df.select(dbf.st_estimatesrid(dbf.st_geomfromtext('wkt')).alias('result')).collect()
Output
[Row(result=32631)]

Return UPS North SRID for a linestring near the North Pole:

Python
df = spark.createDataFrame([('LINESTRING(-180 89, 180 89)',)], ['wkt'])
df.select(dbf.st_estimatesrid(dbf.st_geomfromtext('wkt')).alias('result')).collect()
Output
[Row(result=32661)]

Return None for an empty point:

Python
df = spark.createDataFrame([('POINT EMPTY',)], ['wkt'])
df.select(dbf.st_estimatesrid(dbf.st_geomfromtext('wkt')).alias('result')).collect()
Output
[Row(result=None)]