[GIS] Filling in new field in attribute table based on values of another field in ArcGIS Desktop

arcgis-desktopattribute-table

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?

Best Answer

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!)
Related Question