Select to view content in your preferred language

ArcGIS Pro Field Calculate generating a unique ID from the Object ID

2468
1
04-25-2019 04:40 PM
KellyDunlap
New Contributor

Here is the situation:

I have an existing unique ID field name called Inlet_ID

Each value has been enter as “PINEWOOD-SWI-” because I used a template to create my points. I now need to chance each value so that after the dash there will be sequential numbers PINEWOOD-SWI-001 PINEWOOD-SWI-002 And so on...

My OBJECTID are sequential. I would like to use something like this to calculate the number portion of the ID [INLET_ID]&([OBJECTID]-(OBJECTID—1))

Here is what I would have written in ArcMap [INLET_ID]&([OBJECTID]-39618) ...in this case the OBJECTID would be 39619

So it should calculate (or I want it to calculate PINEWOOD-SWI-1

(I will need to add leading zeros in another step)

Please help!!!!

My supervisors are not familiar with GIS and make rules regarding  the use of the program that don’t always make sense...for example like making new fields for calculations. Is there a way to do with without making a new field? 

0 Kudos
1 Reply
MatthewDriscoll
MVP Alum

For a Python 3 Expression try. 

str(!INLET_ID!) + str(!OBJECTID!-39618)‍‍

There are several ways to pad it with zeros in python and you do not need to add an extra step.  Here is an example.

str(!INLET_ID!) + str(f'{!OBJECTID!-39618:04}')‍‍‍
0 Kudos