I have a file geodatabase raster dataset with 33 bands. Each band is comprised of pixels with values 1-31. This represents 33 years of landuse cover data (with 31 different landuse classes). I'm trying to move from this format to a single TIFF file that has 1 band comprised of pixels with the value 1-33, corresponding to the year that the pixel switched from forest to non-forest. Its a huge file (100GB), so I need to reduce the file size before I can do any analysis.

My plan is to reclassify each band/year into 0 (forest) and 1 (non-forest), then sum all the bands (using the raster calculator, I think?). However, the reclassify tool is only reclassifying a single band.

How do I do this for all the bands.

  • If result of sum will say 2, what that means for you? – FelixIP Apr 3 at 1:41
  • @FelixIP I could use it to calculate the year of deforestation. The dataset goes through 2017, so for each pixel, it would be 2017- (final raster value) = year deforested – Jacy Hyde Apr 3 at 13:56

Big task it is. So set environment settings - cell size, snap raster and extent, to ones of that raster. Run script below from ArcMap or ArcCatalog:

import arcpy
from arcpy.sa import *
## change next 2 lines
## output raster name
outRaster = arcpy.GetParameterAsText(0)

nBands=int(arcpy.GetRasterProperties_management(multiBand, "BANDCOUNT")[0])
for i in range(nBands):
    if i>0:
        deforest=Con((before==ForestCode) & (after != ForestCode),i)
    arcpy.AddMessage("Band %i processed" %i) 
arcpy.AddMessage("Computing last year of deforestation ...")
deforest=CellStatistics(outList, "MAXIMUM", "DATA")

I strongly suggest to test it on a tiny subset first, i.e. clip bit of that monster in the area where deforestation certainly happened.


Replace 184 by value that represents forest in your raster. Script compares consecutive pair of bands - before and after - to find when last deforestation happened.

If you think that 'before' is not defined during first reference, have a better look at the code.

  • thanks for answering. I'm going to be honest, I have absolutely no idea what this code is doing. I have a few specific questions, but would you mind explaining what's happening here in general? I also specifically don't understand the line ForestCode= 184. What is this line doing/ what is 184? also, can you explain what's happening with before==ForestCode?-- "before" isn't defined prior to this line. – Jacy Hyde Apr 5 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.