Sunday, 9 December 2018

Filling in new field in attribute table based on values of another field in ArcGIS Desktop?


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?



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

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...