ST_Rotate

ST_Rotate takes a geometry column and a number and returns a geometry column. The result is the input geometry rotated counterclockwise by the angle specified. You can optionally provide a point column representing the rotation center. By default geometries will be rotated around the origin (0,0).

FunctionSyntax
Pythonrotate(geometry, angle_in_radians, rotation_center=None)
SQLST_Rotate(geometry, angle_in_radians, rotation_center)
Scalarotate(geometry, angleInRadians, rotationCenter)

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

Python and SQL Examples

PythonPythonSQL
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from geoanalytics_fabric.sql import functions as ST

data = [
    ("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_rotate = df.withColumn("rotate", ST.rotate(geometry="geometry",
                                              angle_in_radians=1.57,
                                              rotation_center=ST.centroid("geometry")))

ax = df_rotate.st.plot("geometry", facecolor="none", edgecolor="red")
df_rotate.st.plot("rotate", ax=ax, facecolor="none", edgecolor="blue")
Plotted example for ST_Rotate
Plotted result for ST_Rotate.

Scala Example

Scala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import com.esri.geoanalytics.sql.{functions => ST}
import org.apache.spark.sql.{functions => F}

case class GeometryRow(wkt: String)
val data = Seq(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("rotate", ST.rotate($"geometry",
                                              angleInRadians=F.lit(1.57),
                                              rotationCenter=ST.centroid($"geometry")))

df.select("rotate").show(truncate = false)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|rotate                                                                                                                                                                                                                   |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|{"points":[[-117.62327493604121,34.40333331008169],[-117.7333624971019,34.29342094089738],[-117.5133625668569,34.29324574902101]]}                                                                                       |
|{"paths":[[[-116.71992483981435,33.87762412781743],[-116.76978148515302,34.05766388708072],[-116.83974164662271,34.10771961409705]]]}                                                                                    |
|{"rings":[[[-117.2344930956524,33.569093784554],[-117.27440548703149,33.67912560274493],[-117.09434183796691,33.75898223857155],[-116.89400744416203,34.178822840060775],[-116.82424636437003,33.8787... (286 characters)|
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

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.