Skip to content

RT_AddBand takes a list column and a raster column and returns a raster column. The list represents the cell (pixel) values for creating the new band. The function creates a raster by adding an extra band to the input raster from the provided pixel values. If no_data_value is specified, any pixel matching that value is treated as NoData in the resulting raster.

FunctionSyntax
Pythonadd_band(pixels, raster_col, no_data_value=None)
SQLRT_AddBand(pixels, raster_col, no_data_value)
ScalaaddBand(pixels, raster, noDataValue)

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

Examples

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

from geoanalytics.raster import functions as RT

pixels1 = list(range(9))
pixels2 = list(range(100,109))
data = [(pixels1,)]
df = spark.createDataFrame(data, ["pixels"]) \
    .select(RT.create_raster(pixels="pixels", num_cols=3, num_rows=3, pixel_type="float32").alias("raster")) \
    .withColumn("raster_with_band2", RT.add_band(pixels2, "raster"))

df.select("raster_with_band2").withColumn("pixels", RT.band_values("raster_with_band2", 2)).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-------------------------+---------------------------------------------------------------+
|raster_with_band2        |pixels                                                         |
+-------------------------+---------------------------------------------------------------+
|SqlRaster(2x3x3, Float32)|[100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 106.0, 107.0, 108.0]|
+-------------------------+---------------------------------------------------------------+

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.