Select to view content in your preferred language

Field Calculator completing without error, but no change to Feature

915
2
12-07-2018 12:17 PM
ConorSmith1
New Contributor

Hi there, #arcgispro 2.2. #fieldcalculator

I'm attempting a research project in which I am seeking to categorize a municipality's Property Use Codes as Generalized Land Uses.  For example, "AGRII - Developed Farmland" and "INDGR - Grain Elevator" are both "Agricultural" land uses.  I have created a new field "Land Use Category" and used the following code:

PLY_AssessmentParcels_LandUseCategory = MyFunction(!Assessment_Parcels_CSV_csv_Property_Use_Code!)

def MyFunction(s):
   if ("AGRII" or "INDGR") in s:
      return "Agricultural"
   elif ("VRES2" or "VRES1" or "VINDU" or "VCOMM" or "VAPRK" or "VAGRI" or "CNVAC") in s:
      return "Vacant"
   elif ("STATR" or "SKYWK" or "RAILR" or "ARPRT" or "CMPST" or "CMPSP") in s:
      return "Transportation"
   elif ("RESTR" or "RESSU" or "RESSS" or "RESSD" or "RESRM" or "RESRH" or "RESOT" or "RESMU" or "RESMH" or "RESMC" or "RESMB" or "RESGC" or "RESAP" or "RESDU" or "RESAM" or "CNAPT" or "CNCMP" or "CNDRH" or "CNRES") in s:
      return "Residential"
   elif ("CMCMU" or "CMFBK" or "CMHBH" or "CMHHO" or "CMHMO" or "CMMRH" or "CMOFF" or "CMOGV" or "CMOMC" or "CMRCS" or "CMRCV" or "CMRNS" or "CMRRE" or "CMRRS" or "CMRSM" or "SMRST" or "CMRWC" or "CMVCD" or "CMVSR") in s:
      return "Commercial"
   elif ("CNCOM" or "REFRL" or "CMSTP") in s:
      return "Other"
   elif ("PIRST" or "PIRRT" or "PIRRI" or "PIRPO" or "PIRPK" or "PIRMU" or "PIRGC" or "PIRCC" or "PIRBA" or "PIRAR" or "PIEBM" or "PIECS" or "PIETC") in s:
      return "Recreational"
   elif ("CNIND" or "HYDSS" or "INMHM" or "INMLM" or "INMMI" or "INMMU" or "INWSC" or "INWWH" or "MTSSS" or "TRAPI") in s:
      return "Industrial"
   elif ("PIEMA" or "PIICH" or "PIIDC" or "PIIGC" or "PIIHO" or "PIIMB" or "PIINH" or "PIIPF" or "PIIRE" or "PIISC" or "PIIUC" or "PIMCE" or "PIMFH" or "PIMLI") in s:
      return "Institutional"
   else:
      return

When I run the above code, I often received an error stating "Cannot acquire lock".  After restarting ArcGIS Pro, I can usually get one good run out in which the process completes successfully in about 40 seconds.  The problem is that nothing has changed in my attribute table.  Please note, I'm dealing with about 212,000 records.  The file is stored in a .gdb and I have re-created the feature class in the .gdb with the same issues.  System specs are very reasonable (i7 7800k, 32gb ram, GTX 1080i, etc.)

Any ideas?  Thanks in advance.

0 Kudos
2 Replies
JoeBorgione
MVP Emeritus

Without knowing how s is defined, it's hard saying.  Instead of the  else: return, I'd use else:pass...

That should just about do it....
0 Kudos
DanPatterson_Retired
MVP Emeritus

Select a few records in the table, and run the calculation.  Does it work for a few?

0 Kudos