I'm writing a short python script that includes processing rasters with different geoprocessing tools in ArcGis 10, for example, the three processes below, is this best way to use multiple tools successively, i.e. create temporary rasters in the scratch workspace and then delete them all at the end of the script? By "best", I guess I mean is this the fastest/most efficient way to do this?

# calculate distance (inR is the input raster)
tmp1 = EucDistance(inR, "", "1000", "")

# convert to integer raster
tmp2 = Int(tmp1)

# Reclassify again
arcpy.CalculateStatistics_management(tmp2, "1", "1", "")
tmp3 = Reclassify(tmp2, "VALUE", "0 NODATA", "DATA")

2 Answers 2


For operations that require intermediate data sets, I think that this is really the best/only way to do it.

There are cases where you can create 'in_memory' data sets for use in the next analysis without serializing the data to disk, but for large data sets this probably isn't the greatest idea.

If you wanted to get deeper into the programming, you could use ArcPy (or GDAL) to read your first raster into a numpy array. You could then do the processing in arrays, in memory and just output your final raster.

  • Thanks, it's good to know I'm on the right track. I guess the processing in arrays would be quicker as well, does numpy have ready-made functions similar to geoprocessing ones (I've yet to look at numpy), using R would also be another option, right?
    – CCID
    Mar 10, 2011 at 19:37
  • 4
    There is some great information about using gdal, numpy, and Python in raster GIS in weeks 4-6 of Chris Garrard's Geoprocessing with Python using Open Source GIS at: gis.usu.edu/~chrisg/python/2009
    – DavidF
    Mar 10, 2011 at 19:46

While I agree with DavidF, note that you can actually combine these statements to reduce the amount of serialization to disk as well as avoid any of the sets becoming permanent:

# calculate distance (inR is the input raster), convert to integer raster, & Reclassify again
# calculate statistics is probably not necessary for the reclass coming out of the Int()
tmp3 = Reclassify(Int(EucDistance(inR, "", "1000", "")), "VALUE", "0 NODATA", "DATA")

I've found you can handle some pretty large sets this way. And once they get large enough, you switch to numpy arrays.

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.