ST_Shear takes a geometry column and two numbers and returns a geometry column. The result is the input geometry
with its coordinates translated to a distance proportional to the original coordinate values. The proportions used for x
and y coordinates are specified with the proportion
and proportion
parameters respectively.
Function | Syntax |
---|---|
Python | shear(geometry, proportion |
SQL | ST |
Scala | shear(geometry, proportion |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for shear.
Python and SQL Examples
from geoanalytics_fabric.sql import functions as ST
data = [("POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))", )]
df = spark.createDataFrame(data, ["wkt"]) \
.withColumn("geometry", ST.poly_from_text("wkt", srid=4326))
df_shear = df.select(ST.shear("geometry", proportion_x=0.5, proportion_y=0.5).alias("shear"))
ax = df.st.plot("geometry", facecolor="none", edgecolor="red")
df_shear.st.plot(ax=ax, facecolor="none", edgecolor="blue")
Scala Example
Scala
import com.esri.geoanalytics.sql.{functions => ST}
import org.apache.spark.sql.{functions => F}
case class GeometryRow(wkt: String)
val data = Seq(GeometryRow("POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))"))
val df = spark.createDataFrame(data)
.withColumn("geometry", ST.geomFromText($"wkt", F.lit(4326)))
.select(ST.shear($"geometry", 0.5, 0.5).alias("shear"))
df.show(truncate = false)
Result
+---------------------------------------------------+
|shear |
+---------------------------------------------------+
|{"rings":[[[0,0],[2.5,5],[7.5,7.5],[5,2.5],[0,0]]]}|
+---------------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |