Hi all,
I am trying to rename bands using arcpy.renameBands(), but am having trouble doing so. I have code that used to work, but it appears that renameBands() isn't actually working for me anymore. I am using ArcGIS Pro 3.2.1.
Example code:
rast_Name = r"Path/to/raster.tif"
rast = arcpy.Raster(rast_Name)
rast.bandNames
rast.renameBand("Band_1","NewName")
Thanks for any information.
Hello @WadeWall . this Knowledge Article shows various ways to do this. The ArcPy method described looks different to yours at the bandnames= step. Does that code works any better for you ?
import arcpy im = r"C:\Directory\ArcGIS\Projects\Multiband\Multi_Band.tif" rast = arcpy.Raster(im) bandnames = [arcpy.Raster(b) for b in arcpy.ListRasters()] rast.renameBand('The_Band', 'Band_11') rast.renameBand('The_Band2', 'Band_22') rast.renameBand('The_Band3', 'Band_33') rast.renameBand('The_Band4', 'Band_44') print(rast.bandNames)