Sunday, 11 March 2018

arcgis desktop - Using python to convert string values with Calculate Field in ModelBuilder?


In ArcGIS 10.5, I am building a model that should convert a field of coded values to another code. This seems like it should be a simple if/then statement but I am not getting it. To simplify the process, I populated the target field with the source field's values and then intend on using python to transpose the values. It should be considered a string, but the values are numerical. The field I am trying to edit is "TP_Condi"


In the "Calculate Field" code block:



def reclass:  
if TP_Condi = 3:
return 1
elif TP_Condi = 2:
return 8
elif TP_Condi = 1:
return 3
else:
return "error"




This is the code I was seeking:


enter image description here




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