I have a lot of rows of data, and I want to use the field calculator to give a uniform assignment of
0 1 0 1 0 1 ...
but I don't know how to implement it.
Can someone help me?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
As @PolyGeo mentioned, the modulo operator helps you determine whether a number is pair or not. You can check the "Show Codeblock" box in the field calculator and then write a simple function that determines wheter the row is pair or not and adds a 0 or a 1 depending on the condition
def calc(fid): if fid % 2 != 0: return 0 else: return 1
Then, in the box under you jsut have to call the function using the FID field as an argument.
calc( !FID! )
Note: make sure python is checked as the parser.