AnsweredAssumed Answered

Looping the "Resample" operation

Question asked by a1.s2 on Apr 8, 2013
Latest reply on Apr 8, 2013 by rafaelr
I am trying to resample multiple rasters with the "Resample_management" ArcPy function.

The code below works perfectly:

import arcpy from arcpy import sa arcpy.gp.overwriteOutput=True arcpy.CheckOutExtension("spatial") import glob  Input=glob.glob("D:\Freelancer\oDesk\Create-ArcPy-Scripts\TestFiles\*tif")  for i in Input:     arcpy.Resample_management(i, i+"_1000.tif", "1000 1000", "BILINEAR")


But it saves the output files in the same directory with the input ones. To change this, I modified it a bit.

import arcpy from arcpy import sa arcpy.gp.overwriteOutput=True arcpy.CheckOutExtension("spatial") import glob  Output="D:/Freelancer/oDesk/Create-ArcPy-Scripts/OutputFiles/" Input=glob.glob("D:/Freelancer/oDesk/Create-ArcPy-Scripts/TestFiles/*tif")  for i in Input:     arcpy.Resample_management(i, "'D:/Freelancer/oDesk/Create-ArcPy-Scripts/OutputFiles/%s_1000.tif' % i", "1000 1000", "BILINEAR")


But this throws an error:

Traceback (most recent call last):   File "D:\Freelancer\oDesk\Create-ArcPy-Scripts\testscript-2.py", line 11, in <module>     arcpy.Resample_management(i, "'D:/Freelancer/oDesk/Create-ArcPy-Scripts/OutputFiles/%s_1000.tif' % i", "1000 1000", "BILINEAR")   File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 12407, in Resample     raise e ExecuteError: ERROR 999999: Error executing function. Failed to execute (Resample).


What am I doing wrong?

Outcomes