I have a folder of annual raster land cover maps that are 56x56m spatial resolution. I would like to resample them to 30x30m using a for loop in that folder. I think I am making a small error but unsure of what it may be. The function works but is only able to resample and save one file then it stops.

import arcpy, os
from arcpy import env
arcpy.env.overwriteOutput = True

env.workspace = r"C:\Users\Documents\rasters"
outFolder = r"C:\Users\Documents\new_rasters"

rasterList = arcpy.ListDatasets("*","Raster")    
for inRaster in rasterList: 
    outName = os.path.join(outFolder,str(inRaster))
    outResampled = arcpy.Resample_management(inRaster, outName, "30",  "NEAREST")
  • 3
    I'd first check to make sure that 'rasterList' is containing everything you think it is. Put a print statement after it and confirm what ListDatasets is returning.
    – Brian
    Sep 22, 2016 at 20:02
  • The list variable contains all the raster names I want to manipulation
    – dand
    Sep 22, 2016 at 20:16
  • Wouldn't running the code that you have presented thrown an error in the last line?
    – PolyGeo
    Sep 22, 2016 at 22:28
  • 1
    Cross-posted as stackoverflow.com/q/39647137/820534
    – PolyGeo
    Sep 27, 2016 at 12:13

1 Answer 1


I made the below changes to your code and just ran it on a folder of rasters and it worked. Give it a try.

for inRaster in rasterList:
    print inRaster # just to view progress
    outName = os.path.join(outFolder,str(inRaster))
    arcpy.Resample_management(inRaster, outName, "30",  "NEAREST")

The second argument in Resample_management is already telling it where to save the output.

  • +1 nice catch - I didn't notice the outResampled.save() in the question
    – Midavalo
    Sep 22, 2016 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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