1

I want to reclassify values of 3 different fields AND determine if one of those fields is located inside a different polygon to populate the values of my new field. Everything is raster.

I created a new field (WScore) that I want to populate with numeric values (double) based on the values of 3 different fields - Age_Databa, Riparian_S, and SITE_PHY.

My parameters:

If Age_Databa is 200 or >200 and Riparian_S is not 1 (any number but 1), then WScore should = 5

If Age_Databa is >200 and Riparian_S = 1, then WScore should = 2

If SITE_PHY is <70 and it is in a hydric soil polygon (a raster in my gdb), then WScore = 4

Before realizing the last part about the needing SITE_PHY to be inside the hydric soil polygon, this is what I started with. Pretty sure my syntax is wrong. Any help would be fantastic.

def Reclass(Soils):
global out
 if (Age_Databa <= 200) and (Riparian_S > 1 or Riparian_S < 1):
  out 5
 elif (Age_Databa <= 200) and (Riparian_S == 1):
  out 2
1

Try

def Reclass(Age_Databa,Riparian_S):
  if Age_Databa <= 200 and Riparian_S != 1:
    out = 5
  elif Age_Databa > 200 and Riparian_S == 1:
    out = 2
  return out

You'll need to expand that for your third condition.

I suspect you should be looking at the reclassify tool.

  • I got general error 999999. I'll look into reclassify tool – barnyanka Jan 8 '15 at 22:52
  • I edited the answer so that it should work now. The indentation was incorrect. Python requires consistent indentation. – Fezter Jan 9 '15 at 3:33
  • Now I get error 000539 - says there is invalid syntax in line 1? I tried adding a space between Age_Databa and Riparian_S and that didn't do anything. – barnyanka Jan 9 '15 at 18:23
  • What parameters are you passing to the function? Originally you were giving it ´Soils´ but then never using it in the function. Your original function uses two variables that you did not give to the function. Ultimately we can help you debug a bit, but we cannot really teach you Python from scratch. You could try work on the Python course on Codecademy to get to grips with creating functions in Python and learning the syntax. Finally, as a tip for your third condition, it sounds llike you'll need the raster calculator tool at some stage in order to overlay your raster layers. – Richard Law Jan 9 '15 at 19:32
0

Try this code:

def Reclass(Age_Databa, Riparian_S): if Age_Databa <= 200 and Riparian_S != 1: return 8 elif Age_Databa > 200 and Riparian_S == 1: return 2

Hope it works! I had a similar problem!

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.