ST_Envelope

ST_Envelope takes a geometry column and returns a polygon column. The function returns an envelope for each geometry in the input column, where an envelope is the smallest rectangle that encompasses the input geometry and aligns to the x-axis and y-axis. To find the smallest rectangle that encompasses a geometry but is not axis-aligned, use ST_MinBoundingBox. If the input geometry is a single point, the function will create a degenerate polygon at the location of the point.

FunctionSyntax
Pythonenvelope(geometry)
SQLST_Envelope(geometry)
Scalaenvelope(geometry)

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

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

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 (10 30)",),
    ("MULTIPOINT (0 0, 5 5, 0 5)", ),
    ("LINESTRING (15 15, 10 15, 12 2)", ),
    ("POLYGON ((20 30, 18 28, 22 35, 40 20))", )
]

df = spark.createDataFrame(data, ["wkt"])\
          .select(ST.geom_from_text("wkt").alias("geometry"))

df = df.withColumn("envelope", ST.envelope("geometry"))

ax = df.st.plot("geometry", facecolor="none", edgecolor="red")
df.st.plot("envelope", ax=ax, facecolor="none", edgecolor="blue")
Plotting example for ST_Envelope
Plotted result for ST_Envelope.

Scala Example

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

import com.esri.geoanalytics.sql.{functions => ST}

case class GeometryRow(wkt: String)
val data = Seq(GeometryRow("POINT (10 30)"),
               GeometryRow("MULTIPOINT (0 0, 5 5, 0 5)"),
               GeometryRow("LINESTRING (15 15, 10 15, 12 2)"),
               GeometryRow("POLYGON ((20 30, 18 28, 22 35, 40 20))"))

val df = spark.createDataFrame(data)
              .select(ST.geomFromText($"wkt").alias("geometry"))
              .withColumn("envelope", ST.envelope($"geometry"))

df.select("envelope").show(truncate = false)
Result
1
2
3
4
5
6
7
8
+-----------------------------------------------------+
|envelope                                             |
+-----------------------------------------------------+
|{"rings":[[[10,30],[10,30],[10,30],[10,30]]]}        |
|{"rings":[[[0,0],[0,5],[5,5],[5,0],[0,0]]]}          |
|{"rings":[[[10,2],[10,15],[15,15],[15,2],[10,2]]]}   |
|{"rings":[[[18,20],[18,35],[40,35],[40,20],[18,20]]]}|
+-----------------------------------------------------+

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