ST_Translate

ST_Translate takes a geometry column and two numbers and returns a geometry column. The result is the input geometry translated in the x and y directions by the specified offsets.

FunctionSyntax
Pythontranslate(geometry, x_offset, y_offset)
SQLST_Translate(geometry, x_offset, y_offset)
Scalatranslate(geometry, xOffset, yOffset)

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

Python and SQL Examples

PythonPythonSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

from geoanalytics_fabric.sql import functions as ST

data = [
    ("POINT (-117.05 34.22)",),
    ("MULTIPOINT (-117.55 34.33, -117.66 34.44, -117.66 34.22)",),
    ("LINESTRING (-116.89 33.96, -116.71 34.01, -116.66 34.08)", ),
    ("POLYGON ((-117.27 34.05, -117.22 33.91, -116.96 33.64, -116.66 33.71, -117.08 33.91, -117.16 34.09, -117.27 34.05))", )
]

df = spark.createDataFrame(data, ["wkt"]) \
          .withColumn("geometry", ST.geom_from_text("wkt", srid=4326))

df_translate = df.withColumn("translate", ST.translate("geometry", x_offset=2, y_offset=-1))

ax = df_translate.st.plot("geometry", facecolor="none", edgecolor="red", figsize=(15, 8))
df_translate.st.plot("translate", ax=ax, facecolor="none", edgecolor="blue")
Plotted example for ST_Translate
Plotted result for ST_Translate.

Scala Example

Scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

import com.esri.geoanalytics.sql.{functions => ST}
import org.apache.spark.sql.{functions => F}

case class GeometryRow(wkt: String)
val data = Seq(GeometryRow("POINT (-117.05 34.22)"),
               GeometryRow("MULTIPOINT (-117.55 34.33, -117.66 34.44, -117.66 34.22)"),
               GeometryRow("LINESTRING (-116.89 33.96, -116.71 34.01, -116.66 34.08)"),
               GeometryRow("POLYGON ((-117.27 34.05, -117.22 33.91, -116.96 33.64, -116.66 33.71, -117.08 33.91, -117.16 34.09, -117.27 34.05))"))

val df = spark.createDataFrame(data)
              .withColumn("geometry", ST.geomFromText($"wkt", F.lit(4326)))
              .withColumn("translate", ST.translate($"geometry", 2, -1))

df.select("translate").show(truncate = false)
Result
1
2
3
4
5
6
7
8
+-----------------------------------------------------------------------------------------------------------------------------+
|translate                                                                                                                    |
+-----------------------------------------------------------------------------------------------------------------------------+
|{"x":-115.05,"y":33.22}                                                                                                      |
|{"points":[[-115.55,33.33],[-115.66,33.44],[-115.66,33.22]]}                                                                 |
|{"paths":[[[-114.89,32.96],[-114.71,33.01],[-114.66,33.08]]]}                                                                |
|{"rings":[[[-115.27,33.05],[-115.16,33.09],[-115.08,32.91],[-114.66,32.71],[-114.96,32.64],[-115.22,32.91],[-115.27,33.05]]]}|
+-----------------------------------------------------------------------------------------------------------------------------+

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