Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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")
share|improve this question
up vote 8 down vote accepted

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.

share|improve this answer
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 '11 at 19:37
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: – DavidF Mar 10 '11 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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