Sunday, 20 January 2019

Using conditional statements in ArcGIS Field Calculator?


I have two fields, "P_Area" and "PC_Area", whose sizes I'd like to compare in a third field, "Areas_Equal". The "Areas_Equal" field should contain a "Yes" if the other two are equal and a "No" if they aren't.


How can I do this with Field Calculator and its Python Parser?



Answer



If you're using Python in ArcGIS you may be using an = for comparison instead of an ==


Your code should be similar to the below, if you use Python:


Pre-Logic Script Code - Check "Show Codeblock"


def ifBlock(pArea,pcArea):
if pArea == pcArea:

return 1
else:
return 0

Then in the actual code:


ifBlock(!P_AreaFieldName!,!PC_AreaFieldName!)

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...