I'm trying to string together a field calculator script that will populate all the records of a field at once based upon values in a number of fields. I can't even get the first part of the command to work and can't figure out how to get all the other conditions to fit in.
Here's a simplified version:
NewFIELD: the field I would like to update
Fields = COVER1 and COVER2 (values are three letter codes) and LANDUSE (Values are WET, FOR, COM, RES...). There are other fields I'll be selecting on but for an initial example this should do.
One complication is that there is some overlap between results depending upon how one selects the records. So one record (polygon) could fall into two Forest/Landcover groups (selected first by species composition and secondly by LANDUSE) but I may want to update this new field with only the first Forest class. So I need to do the selections sequentially and explicitly exlude records that have already been defined.
IF [COVER1] = "WWW" OR [COVER1] = "OWW" OR [COVER1] = "SFW" OR [COVER1] = "WAT" THEN
F2 = "Wetland"
ELSE IF ([COVER2] = "WS" OR [COVER2] = "BF" OR [COVER2] = "CE" OR [COVER2] = "LA") AND
[DRAINTYPE] ="IMPERFECT" OR [DRAINTYPE] ="POOR") AND [NewFIELD] <> "Wetland"
F2 = "Forest1"
The first statement updates NewFIELD with "Wetland" for all those records to which it applies. The second statement will apply to some of those that were selected in the first statement but I want them to remain as "Wetland"
As mentioned, I can't even get a simple statement to work so I suspect my initial syntax is horribly wrong.
My first try looks like this and didn't work:
dim f2
if [COVER1] = "SDW" OR [COVER1] ="BSB" then
f2 = "Beach"
end if
So, any thoughts on how I would approach this? I can do it by selecting all applicable records using Select by Attributes and then updating NewFIELD (doing this 9 or ten times) but it'd be nice to do this all at once. And I'm not familiar with Python so don't know where to start with that. But I'd be interested in trying it.
Looking at this thread (If/then VBScript/Python code equivalent to SQL IN ('x','y',z') expression in ArcGIS Field Calculator?) it looks like I may be able to use the SQL IN function but I'm still unclear about it.