Reclassify GUI/form not active in Python script

784
13
02-12-2012 11:04 PM
RogerWiss
New Contributor II
Hi

I have trouble running a Python script, which I added to the ArcToolbox through "Add" -> "Script". The idea is that the user can define the reclassification rules, so the reclassification rules are passed as a parameter.

The problem is that when I open the script, the Reclassify form/GUI is empty and not active (see attached screenshot), i.e. it's not possible to add or change the classification (when clicking any of the buttons, such as Classify, Unique, Add Entry, and Load, nothing happens).

Here the code snippet:

# Get Parameters
infc      = arcpy.GetParameterAsText(0)
recl_rule = arcpy.GetParameterAsText(1)
outfc     = arcpy.GetParameterAsText(2)

# Local Parameters
recl_value = "VALUE"
recl_data  = "DATA"

# Reclassify
outRecl = arcpy.sa.Reclassify(infc, recl_value, recl_rule, outfc, recl_data)
outRecl.save("outfc")


The reclassify input ( GetParameterAsText(1) ) is defined as Data Type "Remap" in the script properties (tab "Parameters").

Version is ArcGIS 10.0 SP3.

Does anyone have an idea why this does not work?

Thanks a lot in advance,
Ralph
Tags (2)
0 Kudos
13 Replies
DanPatterson_Retired
MVP Esteemed Contributor
I suspect that you didn't specify that the properties for that parameter are "obtained from" your input feature class.  Check your parameter properties.
0 Kudos
RogerWiss
New Contributor II
I suspect that you didn't specify that the properties for that parameter are "obtained from" your input feature class.


Unfortunately it's not possible to specify a value for "obtained from". Any other hint?

Thanks
0 Kudos
Paresh__J_Pawaskar
New Contributor
Hi Roger,

The parameter needs to have �??obtained from�?� to be set to the input feature class. But since this is not possible in the UI, there is the validation script which can be used to apply the dependency (highlighted line in the screenshot below.)

This fixes the problem, and now the values are allowed to be edited in the UI.

The bug here seems to be a very old one, since I have seen messages from way back in 2005, but no solutions like the one I have found.

This should definitely solve the problem, as seen in the second attachment.:)

regards,
Paresh
0 Kudos
RogerWiss
New Contributor II

The parameter needs to have �??obtained from�?� to be set to the input feature class. But since this is not possible in the UI, there is the validation script which can be used to apply the dependency (highlighted line in the screenshot below.)

This fixes the problem, and now the values are allowed to be edited in the UI.

The bug here seems to be a very old one, since I have seen messages from way back in 2005, but no solutions like the one I have found.

This should definitely solve the problem, as seen in the second attachment.:)


Hi Paresh,

Thanks a lot, that did the trick!

After inserting your line in the validation script and changing it to ...params[1]... (as my reclassification parameter is at the second position) the Reclassify GUI became active.

And after adapting the example code above to as follows, the script worked fine.


outRecl = arcpy.sa.Reclassify(infc, recl_value, recl_rule, recl_data)
outRecl.save(outfc)


Thanks again,
Roger
0 Kudos
RaphaelR
Occasional Contributor II
thanks to this thread i almost got the behaviour i want, but one part is still missing:
when one loads a classified input raster into the reclassify tool, the remap value table gets automatically populated with the input raster´s current classification.

however, when i load a classified input raster into my custom tool, the remap value table stays empty and i have to add/fill all the classes myself.

how can i get this to fill automatically?
0 Kudos
CarlBeyerhelm
Occasional Contributor
RafealR, did you ever resolve how to populate the remap value table automatically?
0 Kudos
RaphaelR
Occasional Contributor II
RafealR, did you ever resolve how to populate the remap value table automatically?


no, unfortunately not. 😞
maybe i´ll try again with 10.1 - no idea if anything´s changed though...
0 Kudos
David_JAnderson
New Contributor III
The suggested fix does not work for me.  The remap control comes up empty and the classify button is grayed out. 
I tried loading the tool into a interactive python window.  The remap control as a parameter does not expose any methods for any of the buttons on the control such as Load,Save, Classify etc.
It is my opinion that this control does not work and has not worked since at least 2005 as I found those posts about this problem on the prior esri forums.  There was no answer then and no answer now.
0 Kudos
CarlBeyerhelm
Occasional Contributor
A colleague of mine reports that at 10.1, adding the two parameter dependencies to the remap element under initializeParameters in ToolValidator (instead of updateParameters) was all that was needed to activate the �??Classify�?? and �??Unique�?? buttons and populate the remap table listing.  So, there does appear to be hope on the horizon...
0 Kudos