0

I am very new to python. I am using ArcGIS 10.0. I am trying to batch reclassify rasters in a folder and put the outputs into the same folder but with a new name(trying to do this using outputPrefix). this is the script I made:

import arcpy
from arcpy import os
from arcpy.sa import *

inputDir = "E:\BLSK_HSI\practiceLC"
outputDir = "E:\BLSK_HSI\practiceLC"
outputPrefix = "Rec_"

rasList = arcpy.ListRasters()
for raster in rasList:
    reclassField = "VALUE"
    remap = RemapValue([[11,1], [21, 5], [22, 3], [23, 2], [24, 1], [31, 6], [41, 3], [52, 3], [71, 3], [82,3], [90,4], [95, 4]])
    outReclassify = Reclassify(raster, "VALUE",remap, "NODATA")
    outReclassify.save(outputDir)

and I get this error message:

Start Time: Wed May 13 12:06:07 2015
The input raster minimum (-3.1652371883392334) is out of range.
To ensure a correct reclassification, edit ranges or use a different      precision           settings in the Reclassification dialog box.
The input raster maximum (4.0050506591796875) is out of range.
To ensure a correct reclassification, edit ranges or use a different precision               settings in the Reclassification dialog box.
ERROR 010414: Error in creating a Raster from a geodataset.
Failed to execute (Reclassify).
Failed at Wed May 13 12:06:07 2015 (Elapsed Time: 0.00 seconds)

I calculated statistics, built pyramids, etc. Is there something inherently wrong with my code?

1

When saving the raster, you're using outputDir which is a folder, not a valid raster path. Also keep in mind too that your input folder and output folder are the same, so you're also setting up a situation where you'll be overwriting your inputs with your outputs.

For the save, could do something like this:

outRasterName = '{}{}'.format(outputPrefix, raster)
r.save(os.path.join(outputDir, outRasterName))

I would also create a separate folder to distinguish between your inputs and outputs.

You may also want to consider using RemapRange and not RemapValue. Most of those warning messages are coming because you have raster values that don't exactly match with the values you are using in RemapValue.

  • this was helpful. my problem is my input rasters are discrete, so the initial '11' value, for example, corresponds to a type of land use, so it is confusing to me that the error message I receive is the input rasters are out of range because when I look at the individual properties for the raster I see min: 11, max: 95 – tugboat789 May 14 '15 at 13:34
  • ALSO am having trouble now understanding the proper syntax for using os.path.join .... what should be in the '{}{}' part? – tugboat789 May 14 '15 at 14:22
  • I'll edit the answer a bit, I'm currently combining several calls on the same line... – DWynne May 14 '15 at 18:10
  • I'm using format. In this case, each {} is filled by the variables in the following parentheses. So if outputPrefix is "Rec_" and raster is "myraster", then outRasterName becomes "Rec_myraster". – DWynne May 14 '15 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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