Select to view content in your preferred language

renameBands not working

208
1
06-03-2025 12:47 PM
Labels (1)
WadeWall
Regular Contributor

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.

0 Kudos
1 Reply
ChrisUnderwood
Esri Regular Contributor

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 ?

https://support.esri.com/en-us/knowledge-base/renaming-individual-raster-bands-within-arcgis-pro-000...

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)
0 Kudos