1

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?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked May 13, 2015 at 16:28

1 Answer 1

2

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.

answered May 13, 2015 at 20:11
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.