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 is specified, any pixel matching that value is treated as NoData in the resulting raster.
| Function | Syntax |
|---|---|
| Python | add |
| SQL | RT |
| Scala | add |
For more details, go to the GeoAnalytics Engine API reference for add_band.
Examples
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
+-------------------------+---------------------------------------------------------------+
|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
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |