Friday, 9 August 2019

Auto-incrementing field in feature class using ArcGIS Desktop?


So I'm relatively new to ArcGIS and ArcCatalog. I have created a field name of PROJECTID in a feature class in a Personal Geodatabase. The data type is TEXT. This will be a ten digit ID. The first five characters will be a acronym. The sixth character will be a digit that represents the type of feature. It will be a number. The last four characters will be numbers that should be incremented starting at 0001.


Example: WATER-1-0001



Screen shot of the field: enter image description here


So my question is how can I do this in ArcCatalog. I've seen some Python code that will autoincrement like the following:


rec=[OBJECTID]
def autoIncrement(a):
global rec
return "water" + str(a) + "-" + format(rec, '04d')

Again I'm a newbie when it comes to ArcGIS . Now I am getting an error NameError name 'OBJECTID' is not defined.




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