ST_Flip takes a geometry column and a string column, and returns a geometry column. The result is the input geometry flipped
around an axis using the mode specified. You can choose from the following modes:
'
—Flip the geometries around the horizontal axis.X _AXI S' '
—Flip the geometries around the vertical axis.Y _AXI S' '
—Flip the geometries around both the horizontal and vertical axes.BOTH _AXE S'
Function | Syntax |
---|---|
Python | flip(geometry, mode) |
SQL | ST |
Scala | flip(geometry, mode) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for flip.
Python and SQL Examples
from geoanalytics_fabric.sql import functions as ST
data = [
("POINT (0.5 0.5)",),
("MULTIPOINT (4.0 4.5, 5.0 4.5, 5.5 5.0)",),
("LINESTRING (2.0 0.0, 3.0 1.0, 4.0 0.5)", ),
("POLYGON ((5.0 2.0, 6.0 1.0, 5.5 1.0, 4.0 2.0, 5.0 2.0))", )
]
df = spark.createDataFrame(data, ["wkt"]) \
.withColumn("geometry", ST.geom_from_text("wkt"))
df_flip = df.withColumn("flip", ST.flip("geometry", "X_AXIS"))
ax = df_flip.st.plot("geometry", facecolor="none", edgecolor="red")
df_flip.st.plot("flip", ax=ax, facecolor="none", edgecolor="blue")
Scala Example
Scala
import com.esri.geoanalytics.sql.{functions => ST}
case class GeometryRow(wkt: String)
val data = Seq(GeometryRow("POINT (0.5 0.5)"),
GeometryRow("MULTIPOINT (4.0 4.5, 5.0 4.5, 5.5 5.0)"),
GeometryRow("LINESTRING (2.0 0.0, 3.0 1.0, 4.0 0.5)"),
GeometryRow("POLYGON ((5.0 2.0, 6.0 1.0, 5.5 1.0, 4.0 2.0, 5.0 2.0))"))
val df = spark.createDataFrame(data)
.withColumn("geometry", ST.geomFromText($"wkt"))
.withColumn("flip", ST.flip($"geometry", "X_AXIS"))
df.select("flip").show(truncate = false)
Result
+--------------------------------------------------+
|flip |
+--------------------------------------------------+
|{"x":0.5,"y":-0.5} |
|{"points":[[4,-4.5],[5,-4.5],[5.5,-5]]} |
|{"paths":[[[2,0],[3,-1],[4,-0.5]]]} |
|{"rings":[[[5,-2],[6,-1],[5.5,-1],[4,-2],[5,-2]]]}|
+--------------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |