ST_Cast

ST_Cast takes a geometry column and a string and returns a geometry column. The result column contains the input geometries cast to the geometry type specified by the string value. The string value can be 'point', 'multipoint', 'linestring', 'polygon', or 'geometry'. The function will return null when the input geometries cannot be cast to the specified type.

This function is commonly used to:

  • Cast from a specific geometry type to the generic geometry type when merging two geometry columns with different types.
  • Cast from the generic geometry type to a specific geometry type when using a function or tool that requires a specific geometry type as input.
FunctionSyntax
Pythoncast(geometry, geometry_type)
SQLST_Cast(geometry, geometry_type)
Scalacast(geometry, geometryType)

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

Examples

PythonPythonSQLScala
1
2
3
4
5
6
7
8

from geoanalytics_fabric.sql import functions as ST, Point

df = spark.createDataFrame([(Point(10, 10),)], ["point"])

df.printSchema()

df.select(ST.cast("point", "geometry").alias("point")).printSchema()
Result
1
2
3
4
5
root
 |-- point: point (nullable = true)

root
 |-- point: geometry (nullable = true)

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.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close