ST_Transform

ST_Transform takes a geometry column and a spatial reference value and returns a geometry column. The function returns the input geometries transformed into the specified spatial reference. It will also set the spatial reference of the result column. The input geometry column must have a spatial reference set. The spatial reference value must be either a numeric spatial reference (SRID) or a string value in Well-Known Text (WKT) format. Because the most appropriate transformation path may vary based on the extent of the dataset, the original Coordinate System of the data, or the type of analysis you want to conduct, ST_Transform also optionally takes in a list of 4 numeric values representing the extent to consider when determining the best transformation to use. ST_Transform also optionally takes a string value of the transformation path to use when transforming between geographic spatial references. When datum_transform is not specified, ST_Transform will automatically look up the best transformation path to use given the spatial reference of the input geometry column and the spatial reference (specified with sr) to transform into. The datum_transform parameter overrides the session-level transform settings as well as the extent parameter. Both extent and datum_transform are available in Python only and are not supported in SQL.

To learn more about what it means to transform your geometry data, see Coordinate systems and transformations.

To set the spatial reference of a geometry column using spatial reference ID format without transforming the geometries, use ST_SRID.

To set the spatial reference of a geometry column using spatial reference WKT format without transforming the geometries, use ST_SRText.

FunctionSyntax
Pythontransform(geometry, sr, *, extent=None, datum_transform=None)
SQLST_Transform(geometry, sr)
Scalatransform(geometry, sr)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for transform.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
from geoanalytics_fabric.sql import functions as ST

df = spark.createDataFrame([("POINT (10 30)",)],["wkt"])\
    .withColumn("point", ST.point_from_text("wkt", 4326))

df.select(ST.transform("point", 3857, extent=[-30,-50,30,50]).alias("transform"))\
  .withColumn("srid", ST.srid("transform")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-----------------------------------------------+----+
|transform                                      |srid|
+-----------------------------------------------+----+
|{"x":1113194.9079327357,"y":3503549.8435043744}|3857|
+-----------------------------------------------+----+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.