I came across some strange behavior in the Raster.rename method. If you attempt to rename the bands of a Raster, extra default band names will be created. In other words, if you rename 3 bands, you'll end up with 9 bands: 3 correctly named bands and 6 new bands.
import rasterio, pyspatialml, numpy as np
# Create a fake 3-band image for testing
arr = np.random.rand(3, 64, 64)
with rasterio.open("test.tif", "w", width=64, height=64, count=3, dtype=np.float32) as dst:
dst.write(arr)
r = pyspatialml.Raster("test.tif")
renamed = r.rename(dict(zip(r.names, ["Red", "Green", "Blue"])))
Hi @stevenpawley,
I came across some strange behavior in the
Raster.rename
method. If you attempt to rename the bands of a Raster, extra default band names will be created. In other words, if you rename 3 bands, you'll end up with 9 bands: 3 correctly named bands and 6 new bands.I'm running the latest Pyspatialml installed from Github.