1

I'm using the Field Calculator in ArcMap and I need to create a unique ID for every storm drain in my county. An ID Should look something like this: 16-I-003

The first number is the municipal number which is in the column/field titled "Munic"

The letter is using the letter in the column/field titled "Point"

The last number is simply just 1 to however many drains there are in a municipality.

So far I have:

rec=0
def autoIncrement()
pStart=1
pInterval=1
 if(rec==0):
  rec=pStart
 else:
  rec=rec+pInterval
return "16-I-" '{0:03}'.format(rec)

So you can see that I have manually been typing in the municipal number, the letter, and the hyphens. But I would like to pull the first number and letter from the fields: Munic and Point so I don't have to manually type them in each time it changes. I was hoping I could just put !Munic! and !Point! in my return statement before the .format(rec) or somehow work it in there.

I'm a beginner when it comes to python and ArcMap, so please dumb things down a little. The simpler the better!

Katie B.
  • 807
  • 1
  • 7
  • 18
  • 2
    This is a similar question http://gis.stackexchange.com/questions/95249/how-to-auto-increment-a-field-in-a-feature-class/95254#95254 – GISHuman Jun 26 '14 at 18:46

1 Answers1

2

I am unclear about your function's logic, but I would approach it like this...

Expression:

autoIncrement(!Munic!, !Point!)

Expression Type:

PYTHON_9.3

Code Block:

rec = 0
def autoIncrement(munic, point)
  pStart=1
  pInterval=1
  if(rec==0):
    rec=pStart
  else:
    rec=rec+pInterval
  return '{0}' "-" '{1}' "-" '{2:03}'.format(munic, point, rec)  
ericchiasson
  • 1,092
  • 6
  • 7