ST_BinCenter

ST_BinCenter takes a bin column and returns a point column. The point column represents the center point of each bin.

FunctionSyntax
Pythonbin_center(bin)
SQLST_BinCenter(bin)
ScalabinCenter(bin)

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

Python and SQL Examples

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

from geoanalytics_fabric.sql import functions as ST, Polygon

data = [
    (Polygon([[[0,0],[0,10],[10,10],[10,0],[0,0]]]),),
    (Polygon([[[20,0],[30,20],[40,0],[20,0]]]),),
    (Polygon([[[20,30],[25,35],[30,30],[20,30]]]),)
]

df = spark.createDataFrame(data,["polygon"])\
    .withColumn("bin_center", ST.bin_center(ST.square_bin("polygon", 2)))

ax = df.st.plot("polygon", facecolor="none", edgecolor="red")
df.st.plot("bin_center", ax=ax, facecolor="none", edgecolor="blue")
Plotting example for ST_BinCenter
Plotted result for ST_BinCenter.

Scala Example

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

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

case class PolygonRow(polygon: Polygon)
val data = Seq(PolygonRow(Polygon(Point(0, 0), Point(0, 10), Point(10, 10), Point(10, 0), Point(0, 0))),
               PolygonRow(Polygon(Point(20, 0), Point(30, 20), Point(40, 0), Point(20, 0))),
               PolygonRow(Polygon(Point(20, 30), Point(25, 35), Point(30, 30), Point(20, 30))))

val df = spark.createDataFrame(data)
              .withColumn("bin_center", ST.binCenter(ST.squareBin($"polygon", 2)))

df.select("bin_center").show(truncate = false)
Result
1
2
3
4
5
6
7
+---------------+
|bin_center     |
+---------------+
|{"x":5,"y":5}  |
|{"x":31,"y":7} |
|{"x":25,"y":31}|
+---------------+

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