Skip to content

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.

FunctionSyntax
Pythonband_statistics(raster_col, band_id)
SQLRT_BandStatistics(raster_col, band_id)
ScalabandStatistics(raster, bandId)

For more details, go to the GeoAnalytics Engine API reference for band_statistics.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8

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)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-----------------------------------+
|band_statistics                    |
+-----------------------------------+
|{1.0, 4.0, 2.5, 1.2909944487358056}|
+-----------------------------------+

Version table

ReleaseNotes

2.0.0

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.