1

I am a newbie of python teaching myself using the arcpymanual. I am running a Reclassify script on slope grids. It works fine for the first loop then I get an error message for the remap line. I cannot figure out what the problem is because I copied the syntax from the arcpy manual. Is it due to loop syntax?

Runtime error Traceback (most recent call last): File "", line 21, in TypeError: 'RemapRange' object is not callable

SCRIPT:

import arcpy
from arcpy import env
from arcpy.sa import *
# Set the current workspace
arcpy.env.workspace = r"C:\workspace\rsn\pippi"
# Overwrite pre-existing files
arcpy.env.overwriteOutput = True
# Process: Reclassify
rasters = arcpy.ListRasters("s_*", "GRID")
for raster in rasters:
 print(raster)
 outRaster = r"C:\workspace\rsn\pippi\re_" + raster
 print(outRaster)
 RemapRange = RemapRange([[0, 15, 0], [15, 30, 1], [30, 90, 2]])
 outReclassRr = Reclassify(raster, "Value", RemapRange, "DATA")
 print outReclassRr
 outReclassRr.save(outRaster)

Can anyone give any suggestions?

ahmadhanb
41.8k5 gold badges55 silver badges109 bronze badges
asked Feb 21, 2017 at 12:47

1 Answer 1

0

Your variable RemapRange is named the same as the object RemapRange which is not good coding practice. Try renaming that statement to something like:

myRemapRange = RemapRange([[0, 15, 0], [15, 30, 1], [30, 90, 2]])

I would also recommend to place that statement before the for loop since it is static variable and does not need re-created for each image.

rasters = arcpy.ListRasters("s_*", "GRID")
myRemapRange = RemapRange([[0, 15, 0], [15, 30, 1], [30, 90, 2]])
for raster in rasters:
 # continue on with logic
answered Feb 21, 2017 at 13:36
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.