RT_BandValues takes a raster column and a numeric column that represents the band ID and returns an array column.
This array contains the cell values for the specified band. 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_values.
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_values("raster", 1).alias("band_values")).show(truncate=False)Result
+--------------------+
|band_values |
+--------------------+
|[1.0, 2.0, 3.0, 4.0]|
+--------------------+Version table
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |