Reclassify failure: cannot set input into parameter remap

131
7
10-22-2020 02:57 PM
New Contributor III

I am reclassifying texture classes of a soil raster into integers:

import arcpy
from arcpy import env

arcpy.CheckOutExtension('Spatial')

soil_path = 'C:\\Users\\....\\soil.gdb\\soil_raster"

class_map = [('Loamy very fine sand', 1), ('Sandy loam', 2), ('Loamy fine sand', 1), ('Silt', 4), ('Sandy clay', 11), ('Fine sand', 3), ('Very fine sandy loam', 2), ('Coarse sand', 3), ('Loamy sand', 1), ('Clay', 7), ('Very fine sand', 3), ('Silty clay', 9), ('Coarse sandy loam', 2), ('Loamy coarse sand', 1), ('Sand', 3), ('Sandy clay loam', 5), ('Clay loam', 6), ('Silty clay loam', 10), ('Silt loam', 4), ('Loam', 8), ('Fine sandy loam', 2)]

remap_values = arcpy.sa.RemapValue(class_values)

soil_reclass = arcpy.sa.Reclassify(in_raster='soil_path', reclass_field='texcl', remap=remap_values)

This returns an error

ExecuteError: ERROR 000622: Failed to execute (Reclassify). Parameters are not valid.
ERROR 000628: Cannot set input into parameter remap.

I am able to run the Reclassify tool just fine in ArcMap with these values, but copying the code as Python snippet doesn't help because once I format it for a standalone script, the error returns. (One weird thing: when pasting the snippet, some of the strings were unquoted, like clay instead of 'clay'.)

There was a similar question on here for which the answer was to check for repeat keys in the remap, but there aren't any here. Any ideas? Banging my head against my desk on this one.

Reply
0 Kudos
7 Replies
MVP Frequent Contributor

strange... the help and their examples show a list of lists

... is a list of lists, with the inner lists being composed of two components....

and you have a list of tuples... hopefully they are just looking for a list of iterable containers and aren't that fussy...

worth a look though


... sort of retired...
New Contributor III

Hey Dan - good eye. Unfortunately that still doesn't work. Must be something wrong with my raster file ...

Reply
0 Kudos
MVP Frequent Contributor

figured it out

class_map
[('Loamy very fine sand', 1),
('Sandy loam', 2),
('Loamy fine sand', 1),
('Silt', 4),
('Sandy clay', 11),
('Fine sand', 3),
('Very fine sandy loam', 2),
('Coarse sand', 3),
('Loamy sand', 1),
('Clay', 7),
('Very fine sand', 3),
('Silty clay', 9),
('Coarse sandy loam', 2),
('Loamy coarse sand', 1),
('Sand', 3),
('Sandy clay loam', 5),
('Clay loam', 6),
('Silty clay loam', 10),
('Silt loam', 4),
('Loam', 8),
('Fine sandy loam', 2)]

remap_values = arcpy.sa.RemapValue(class_values)
Traceback (most recent call last):

File "<ipython-input-15-28e6a22766e3>", line 1, in <module>
remap_values = arcpy.sa.RemapValue(class_values)

NameError: name 'class_values' is not defined

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

You put class_values into sa.RemapValue instead of class_map

with the fix

 dir(remap_values)
['_CompoundParameter__propertyGetter', '_CompoundParameter__propertySetter',
'___keyword', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__',
'__esri_toolinfo__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
'__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__remapTable', '__repr__', '__setattr__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', '_addProperty', '_keyword',
'_toRepresentation', '_toString', '_useDefault', 'remapTable']‍‍

... sort of retired...
New Contributor III

Oh haha, my "minimal example" seems to be poorly written....

Thank you for catching that. I rewrote it as you suggested and now the remap_values looks like this:

remap_values
RemapValue([['Loamy very fine sand', 1], ['Sandy loam', 2], ['Loamy fine sand', 1], ['Silt', 4], ['Sandy clay', 11], ['Fine sand', 3], ['Very fine sandy loam', 2], ['Coarse sand', 3], ['Loamy sand', 1], ['Clay', 7], ['Very fine sand', 3], ['Silty clay', 9], ['Coarse sandy loam', 2], ['Loamy coarse sand', 1], ['Sand', 3], ['Sandy clay loam', 5], ['Clay loam', 6], ['Silty clay loam', 10], ['Silt loam', 4], ['Loam', 8], ['Fine sandy loam', 2]])

dir(remap_values)
['_CompoundParameter__propertyGetter', '_CompoundParameter__propertySetter', '___keyword', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__esri_toolinfo__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__remapTable', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_addProperty', '_keyword', '_toRepresentation', '_toString', '_useDefault', 'remapTable']

So everything looks great, unfortunately it is still returning the same error for me.

Reply
0 Kudos
MVP Frequent Contributor

Check to see if you have all the classes (ie nodata) and check your raster


... sort of retired...
Reply
0 Kudos
New Contributor III

Hmm no that doesn't seem to help! Thanks for helping though. I figured out a way to make this work which is from from elegant. But basically I am just re-using the "copy snippet as python" bit from running reclassify in ArcMap.

arcpy.gp.Reclassify_sa("C:/Users/.../soil.gdb/soil_raster", "texcl", "'Silt loam' 4;'Sandy loam' 2;'Fine sandy loam' 2;Loam 8;'Coarse sandy loam' 2;'Loamy sand' 1;Sand 3;'Loamy fine sand' 1;'Sandy clay loam' 5;'Very fine sandy loam' 2;'Coarse sand' 3;'Clay loam' 6;'Loamy coarse sand' 1;'Fine sand' 3;'Silty clay loam' 10;'Silty clay' 9;Clay 7;'Very fine sand' 3;Silt 4;'Loamy very fine sand' 1", soil_reclass, "DATA")

You'll see it's weird because "clay" and "sand" don't have quotation marks around them, which seems random, so I can't dynamically generate these remap values should I need to change the classes. But I can run this in Python.

Reply
0 Kudos
MVP Frequent Contributor

That sounds like a bug... I would report it, there shouldn't be a reason to have random omissions of text bits

There are bugs though

BUG-000121215: Remap Function remaps incorrect values in ArcGIS Des.. 

BUG-000086955: Changes to the range values in the remap table of th.. 


... sort of retired...
Reply
0 Kudos