2

When I run the Reclassify tool from arcmap 10.1 and assign a 1 to each of the crop types it combines them into one class. However, when I try to recreate this in python it does not merge the crop class types into one class. Below is the code:

Reclassify code

These are the parameters and results when I run it directly from the arc tool box and not from python. Below is what I am trying to reproduce using python:

Reclassify tool

ToC after Reclassify tool

  • 2
    Can you copy and paste your code into your question, rather than including it as a screenshot? – Dan C Aug 13 '14 at 20:06
  • I was going to repost the code in non screen shot form, per Dan's request, but first I tried radouxju's suggestion and it worked. So I will post the solution below. – dugg Aug 14 '14 at 12:37
1

An easy fix is to save your look up table (save button on the "reclassify form") once, then you can reuse it several times using ReclassByTable instead of "Reclassify" in your script. "Lookup" would probably be even better.

In order to minimize the potential sources of problem, I would also suggest that you avoid special characters such as spaces in the names of your classes. "_" can be used in place of " ".

0

The solution as suggested by radouxju was to eliminate spaces from the CLASS_NAME values in the attribute table. For what ever reason, it was not reading them correctly in the remapValue statement even though they were quoted.

Once the attribute table was edited to have string values without spaces I changed the remapValue statement to reflect the new spaceless values. Below is the code change that fixed the problem:

Code changed from:

myRemap = RemapValue([["Soybeans",1],["WinWht Soybeans",1],["Soybeans Cotton",1],["Soybeans Oats",1],["Corn Soybeans",1],["Barley Soybeans",1]])

To:

myRemap = RemapValue([["Soybeans",1],["WinWhtSoybeans",1],["SoybeansCotton",1],["SoybeansOats",1],["CornSoybeans",1],["BarleySoybeans",1]])

Thanks to radouxju for the thoughtful suggestion.

  • This answer is effectively the same as radouxju's. Rather than posting the same answer again, you should upvote radouxju's answer and accept it. – Fezter Aug 15 '14 at 3:06

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.