Skip to content

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 return null.

FunctionSyntax
Pythonband_mask(raster_col, band_id)
SQLRT_BandMask(raster_col, band_id)
ScalabandMask(raster, band)

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

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_mask("raster", 1).alias("band_mask")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+------------------------+
|band_mask               |
+------------------------+
|[true, true, true, true]|
+------------------------+

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.