ST_Buffer

ST_Buffer takes a geometry column and a numeric distance value and returns a polygon column. The resulting buffer polygons represent the area that is less than or equal to the specified planar distance from each input geometry. The distance can be specified as a single value or a numeric column. The distance value should be in the same units as the input geometry. For example, if your input geometry is in a spatial reference that uses meters, you should specify the distance in meters. To create a buffer polygon using geodesic distance calculations use ST_GeodesicBuffer.

FunctionSyntax
Pythonbuffer(geometry, distance)
SQLST_Buffer(geometry, distance)
Scalabuffer(geometry, distance)

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

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

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
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("buffer", ST.buffer("geometry", 2))

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

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
18
import com.esri.geoanalytics.sql.{functions => ST}
import org.apache.spark.sql.{functions => F}

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("buffer", ST.buffer($"geometry", 2))
              .withColumn("buffer_area", F.round(ST.area($"buffer"), 3))


df.select("buffer", "buffer_area").show()
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
+--------------------+-----------+
|              buffer|buffer_area|
+--------------------+-----------+
|{"rings":[[[12,30...|     12.557|
|{"rings":[[[2,0],...|     37.672|
|{"rings":[[[12,0]...|     83.951|
|{"rings":[[[40,18...|    188.535|
+--------------------+-----------+

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.