Tuesday 23 June 2015

Field calculator if and elseif statement with values in ArcGis 10.1


Trying to figure out how to get this "Headwater" column to indicate "Yes" (or 1) if the value of "NextDown_Copy" is "" and "No" (or 0) if it has any other value (eg. 7100381010).


enter image description here


I attempted to try figuring out the Python code to do this using 1 and 0 coding (although I'd rather use Yes and No) (as illustrated below) but keep getting errors. I consulted a few other posts (another one), but still wasn't able to find the problem.


enter image description here



Answer



Here's a simple expression with no need to define a function in the codeblock:


Headwater =


0 if !NextDown_Copy! else 1


This checks if each value of NextDown_Copy is truthy (i.e. not a null, 0, empty string), and returns a 0 if so, otherwise it returns a 1.


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