Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have parcel, Buildings layers, without any information attribute table, and i want to replace "NULL" values with numbers form 1 to 2000, in "Parcel ID", or "Building ID" field thank you.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Here is a code block for the Field Calculator that will do what you require.

  1. Open the attribute table
  2. Select all of the records that contain a NULL value in the desired field
  3. Open up the Field Calculator and insert this code in the appropriate sections.

Accumulative and sequential calculations
Calculate a sequential ID or number based on an interval.


Expression Type:

Code Block:
def autoIncrement():
 global rec
 pStart = 1 #adjust start value, if req'd 
 pInterval = 1 #adjust interval value, if req'd
 if (rec == 0): 
  rec = pStart 
  rec = rec + pInterval 
 return rec

This code sequence is taken from the ArcGIS 10.0 Desktop Help: Calculate Field Examples

I would highly recommend that you browse through the help documentation in that file and in the other help sections for ArcGIS, as there are many useful examples and code samples to pull from.

Edit -----------

Enter the code above, into the Field Calculator as shown in the screen shot below: You would enter the code into the sections as detailed below:

  1. Choose Python as the Parser
  2. Pre-Logic Script Code: Enter code listed under Code Block
  3. Under the field name, in this case, RD20FULL =: Enter code listed under Expression
  4. Press OK

Example Field Calculator Code Entry

share|improve this answer
thank you very much @Get Spatial, here is the steps that i followed it, i added parcel layer into arcmap10, then opened attribute table and right click on "parcel ID" that have "NULL" values choose field calculator, finally copy and paste python code in the box, when click ok, an error message appears, "there was a failure during processing check the geoprocessing results window for detail", and this is the number error"000539 : Error message from Python" – GIS Man Aug 18 '12 at 8:10
i am still waiting for any guideline for how to resolve this error. – GIS Man Aug 18 '12 at 16:21
@GISMan - I have updated my answer and included an example of how the code I originally provided, should be entered in the Field Calculator. – Get Spatial Aug 19 '12 at 8:21
WOOOW thank you very much, it is work done, you are my hero, thank you again. – GIS Man Aug 19 '12 at 8:47
+1 - This piece of code has helped me out in several situations. – Cindy Williams Aug 20 '12 at 5:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.