How can I access the bands of a raster layer?

09-01-2017 11:44 AM
New Contributor II

I've used MakeNetcdfRasterLayer to create a raster layer. That raster layer has 365 individual bands.

Now I need to apply zonal statistics to each of those bands. The normal way I would do this is to pass rastername/Band_1 to the zonal statistics function, then rastername/Band_2 and so forth. However when I do that here it says that the specified input doesn't exist. Am I going about this the wrong way?

0 Kudos
3 Replies
MVP Legendary Contributor

does it use band names or index numbers?

0 Kudos
Esri Esteemed Contributor

Can you share your code and if possible a part of your data? Possibly it is not the "Band_#" part that is causing the problem.

What if you navigate to your data using the catalog window and copy the path of a selected band, does that correspond to the path you are using in your code?

(not a good a example, but it explains what I mean)

Occasional Contributor III

Hi Justin,

I've come across situations when the names of bands were Layer_1, Layer_2, etc., it does not always have to be Band_1, Band_2, etc.

Perhaps try to list the individual bands programmatically as shown here:

python - Access individual bands and use them in map algebra - Geographic Information Systems Stack ... 

The main idea is to set your main raster dataset as a workspace and then use arcpy.ListRasters() function.