RT_BandStatistics takes a raster column and a numeric value which is the band ID and returns a struct column.
This struct includes statistics about the raster such as minimum, maximum, mean, and standard deviation.
The band statistics provide valuable estimates of the raster's statistical properties but it is important to note that
these estimates may not always reflect the exact statistics of the raster data.
If the band ID is out of range, the function will return null.
| Function | Syntax |
|---|---|
| Python | band |
| SQL | RT |
| Scala | band |
For more details, go to the GeoAnalytics Engine API reference for band_statistics.
Examples
from geoanalytics.raster import functions as RT
data = [([1,2,3,4], )]
df = spark.createDataFrame(data, ["pixels"]) \
.withColumn("raster", RT.create_raster("pixels", 2, 2, "int32"))
df.select(RT.band_statistics("raster", 1).alias("band_statistics")).show(truncate=False)+-----------------------------------+
|band_statistics |
+-----------------------------------+
|{1.0, 4.0, 2.5, 1.2909944487358056}|
+-----------------------------------+Version table
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |