Skip to content

RT_NumBands takes a raster column and returns a numeric value that represents the number of bands in the raster.

FunctionSyntax
Pythonnum_bands(raster_col)
SQLRT_NumBands(raster_col)
ScalanumBands(raster)

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

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, "float32"))

df.select(RT.num_bands("raster").alias("num_bands")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+---------+
|num_bands|
+---------+
|1        |
+---------+

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.