I have a pair of data sets with identical schemes; one is a sort of reference layer (A) and the other one is an editable working layer (B). These data sets eventually make their way into a web map for Collector. There is a field using subtypes that help restrict domains for other fields, which looks like:
My workflow includes appending the data in layer (B) to layer (A). The problem is that the subtype field displays its numeric code instead of its description in pop-ups for the web map. For ease of use I need the description to display, so I wanted to calculate the description into a second text field. Eventually this will be a python script, but for testing purposes I've been using the field calculator in ArcMap to check that the code is right before I incorporate it into my larger script. The below example successfully runs without error, but instead of returning the description in my "if" statement, I'm always getting the "else: nope".
Pre-logic script code
def myFunc(ftype_int): if (ftype_int == 4): return "Generic Karst" else: return "nope"
In place of the (ftype_int == 4) I've tried (ftype_int == "4"), (ftype_int == "Generic Karst"), (ftype_int == "4 - Generic Karst"), but# have had no luck.
How do I get the field calculator to properly read the values in the subtype field? Hope this makes sense.
def myFunc(ftype_int): if (ftype_int == 4): return "Generic Karst" else: ftype_int
Hm, modifying my "else" statement to the above gives me a <NULL> value in my FTYPE field.
There are only the two fields: "ftype_int" which is the 'short' field that has the subtype values, and "ftype" which is the 'text' field I'm trying to calculate to.
Plugging in some of the other unrelated fields from the table into my "else" statement, I've noticed that everything gives me a <Null> value for my ftype field. The only thing that hasn't given me a <Null> return is telling it to print something specific like "nope".
Thanks for taking the time
I ended up using another method because I just couldn't figure out what the heck was wrong here. Didn't seem to be able to read any field I tried, so must not be an issue specific to subtype. Instead I broke it into two steps: calculated the numeric codes into my string field, then used the .replace() function to swap out the codes and descriptions. Would still be curious to know why I couldn't get the if/else statements to work, though.