RT_BandMask takes a raster column and a numeric column that represents the band ID and returns an array column. This array contains the mask values for the specified band.
A mask is essentially a boolean array of the same length as the data. If the value at the index is false, the cell is not valid and should not be included for analysis.
If the band ID is out of range, the function will returnnull.
| Function | Syntax |
|---|---|
| Python | band |
| SQL | RT |
| Scala | band |
For more details, go to the GeoAnalytics Engine API reference for band_mask.
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_mask("raster", 1).alias("band_mask")).show(truncate=False)Result
+------------------------+
|band_mask |
+------------------------+
|[true, true, true, true]|
+------------------------+Version table
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |