ST_SquareBin takes a geometry column and a numeric bin size and returns a bin column. The output column contains a single square bin for each record in the input column. The specified bin size determines the height of each bin and is in the same units as the input geometry. The centroid of the input geometry is guaranteed to intersect with the bin returned but is not necessarily coincident with the bin center. Use ST_BinGeometry to obtain the geometry of each result bin.
For more details, go to the GeoAnalytics Engine API reference for square_bin.
from geoanalytics.sql import functions as ST, Polygon data = [ (Polygon([[[0,0],[0,10],[10,10],[10,0]]]),), (Polygon([[[20,0],[30,20],[40,0]]]),), (Polygon([[[20,30],[25,35],[30,30]]]),) ] df = spark.createDataFrame(data,["polygon"])\ .withColumn("square_bin", ST.bin_geometry(ST.square_bin("polygon", 5))) ax = df.st.plot("polygon", facecolor="none", edgecolor="red") df.st.plot("square_bin", ax=ax, facecolor="none", edgecolor="blue")