1

I have added a new field (Category) in an attribute table of a shapefile and I would like to fill it with numbers, 0 or 1, based on the numbers of another field (Calorific value) of the same attribute table.

That means that if the Calorific value is higher than 15, then I would like to fill in the corresponding cells of the (new) Category field with 1. If the Calorific value is less than 15, then the rest cells of the (new) Category field to be filled in with the number 0.

Is there a way to do this automatically rather than manually?

1 Answer 1

4

You can do this automatically using Field Calculator with a code block.

def classify(field):
    if (field > 15):
        return 1
    elif (field <= 15):
        return 0

classify( !CalorificValue!)
1
  • 1
    And select Python rather than default VB Script
    – aldo_tapia
    Aug 10, 2017 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.