The first attached script successfully reclassified your AK NLCD data in about 15 minutes (i7, 12GB RAM machine). Since the original dataset is almost 7GB you may be encountering memory issues. If you cannot process the entire dataset in one chunk, try splitting it up with the second script prior to reclassification. My recommendation is to take a small subset of the data (Right click raster layer in TOC > Data > Export Data > Extent (Data Frame) and test the first script. Once you dial in the parameters for the reclassify command, then move toward reclassifying the entire dataset or splitting it up. Alternatively, try downloading the 64 bit Background Geoprocessing product for ArcGIS 10.1 SP1, available here. Best of luck.
Script 1
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Overwrite output
env.overwriteOutput = 1
# Set environment settings
env.workspace = r'C:\temp'
Dir = env.workspace
# Set local variables
inRaster = Dir + "\\" + "nlcd_subset.img"
reclassField = "Value"
remap = RemapValue([[0, 40, 0], [41, 41],[42,42], [43,43], [44, 256, 0]])
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute Reclassify
outReclassify = Reclassify(inRaster, reclassField, remap, "NODATA")
# Save the output
outReclassify.save(r"C:\temp\nlcd_test.img")
Edit:
If you need to split your data up prior to processing, this script should help:
Script 2
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Overwrite output
env.overwriteOutput = 1
# Set environment settings
env.workspace = r'C:\temp'
Dir = env.workspace
# Set local variables
inRaster = Dir + "\\" "nlcd" + "\\" + "nlcd_ak.img"
outFolder = Dir
reclassField = "Value"
remap = RemapValue([[0, 40, 0], [41, 41],[42,42], [43,43], [44, 256, 0]])
# Split Rasters
# Equally split a large TIFF image by number of images
arcpy.SplitRaster_management(inRaster, outFolder, "split", "NUMBER_OF_TILES", "#",
"NEAREST", "2 2", "#", "4", "PIXELS",\
"#", "#")
# List rasters for processing
rasters = arcpy.ListRasters()
for ras in rasters:
print "processing..." + ras
# Define new name
name = "class_" + ras
# Execute Reclassify
outReclassify = Reclassify(ras, reclassField, remap, "NODATA")
# Save the output
outReclassify.save(Dir + "\\" + name)
reclassify
should be a last resort, because it is so general in scope that it likely uses methods that are less efficient than can be obtained when the reclassification is easy to express arithmetically or logically. In the present case, the criterion for reclassification is so simple you ought first to try it withCon
or even straight arithmetical operations (because they are fast). For instance,"grid" * ("grid" >= 41) * ("grid" <= 43)
ought to do it. RAM shouldn't be an issue--Spatial Analyst automatically windows its raster I/O and these are local operations.Inlist
is a nice solution (+1). I was able to usecon
and monitored RAM usage during the operation. It never exceeded 180 MB, which is barely greater than the RAM used just to launch ArcMap. The tiling in ArcGIS is automatic--you don't even get to control it (unless you are programming to the C/Fortran interface). It appears that RAM limitations are of little concern.con
worked for me as well, with the condition"Value" >= 41 AND "Value" <= 43
. I would have gone with this solution, but I'm not sure if additional raster values are going to be of interest in the future. Obviously I could add anOR
into the where clause, but then it starts to become more complicated.InList
seems the most straight-forward solution in regards to readability and maintainability.