[GIS] Generating Values in Attribute Table using ArcGIS Desktop

arcgis-10.1arcgis-desktopattribute-table

In the attribute table within GIS, I have a certain column with ascending values, and I want to assign ID numbers (for easier readability and display) to a corresponding column. So for instance:

Feet Away   |   ID
 200.1      |   1
 302.0      |   2
 500.9      |   3
 ...        |   ...
 highest    |  highest

I would want to be able to generated the 1, 2, 3, etc.

I do not know how to generate the ID field given that the 'Feet Away' field is already generated and in order. I know that if I had access to some java or javascript function, I would make a loop which started at the first element (the ID field corresponding to 200.1 in the above, or 1), iterate it for as long as there is a value in the feet away column, and fill the ID field with a number one larger than the previous number added. But I do not know how to do that with the attribute table.

How do I generate a column of increasing integers?

Do I need to add code from a different source?

It seems like a pretty easy computer science problem, I just do not know how to do it within a GIS context.

Best Answer

Well, if you've got a table that natively (sorted by FID or ObjectID as applicable) is NOT sorted how you want it, and you want to view the table sorted by a specific field(s) with a unique ID field in order of the sort, you don't need to mess with any scripting at all.

Just use the SORT geoprocessing tool that is included in ArcGIS (In ArcToolbox > Data Management Tools > General > Sort ). This tool should do what you're asking for because there will be a new OID/FID for the resulting dataset that is in order with the sorted values.

More info on the Sort GP tool is available at http://resources.arcgis.com/en/help/main/10.1/index.html#/Sort/001700000057000000/