Reclass attribute table, problem

365
1
07-29-2014 08:49 AM
Highlighted
New Contributor

Hey there!

I have an attibute table with values from -1 to +1. I need to reclassify them in 5 classes from 1 ... 5.
Class 1 should be from -1 to -0.6, Class 2 from -0.6 to -0.2, .... Class 5 from 0,6 to 1.

And how can I exclude values out of my range from -1 to 1, in case I forgot something?

Has anyone an idea how to write this in VBscript or Phython? I sit here, with no idea of any languages, for the whole afternoon, Help and examples didnt help ne, neither google.

probably a question of seconds if u know how to do it.

Thanks in Advance!

0 Kudos
1 Reply
Highlighted
Frequent Contributor

Actually this would be relatively quick and easy to do by hand, just do select by attribute,

do a field calculator on your class field.

I'd made a new field for putting the class numbers in, select python as your parser, and clcik the check mark to show the code block.

in the prelogic script code put in

def Reclass(Value):

  if ( Value <= 1) and ( Value >= .6) :

    return 1

  elif ( Value < .6 ) and ( Value >= .2):

    return 2

  elif ( Value < .2) and ( Value >= -.2):

    return 3

  elif (Value < -.2) and ( Value >= -.6):

    return 4

  elif ( Value < -.6) and ( Value >= -1):

    return 5

  else:

    return 0

In the block below it put:

Reclass("doubleclickonthefieldyouneedhere")

your field in the Reclass parentheses should be between exclamation points, not quotes, and be the fields that has your original values in it.

Hope this helps

0 Kudos