Label consecutively based on Lat/Long
I'd like to dictate the way labels are applied to a long list of facilities.
I'm going to have a map with an accompanying excel spreadsheet of data for each point based on the label ID of the point. The Label ID will just be a number.
To facilitate work in the field, and to avoid randomly looking in the spreadsheet of points...I'd like neighboring points on the map to have relatively close labels IDs in the list of spreadsheet data. So I thought if I sort on Lat or Long, then create a Label ID field, it would keep things that are relatively close on the map to be relatively close in the spreadsheet.
So I'm using this VBA script to assign a number consecutively to each record, and will use it as the Label ID.
Static rec As Long
Static i As Long
Dim lStart As Long
Dim lInterval As Long
lStart = 1
lInterval = 1
If (i = 0) Then
rec = lStart
rec = rec + lInterval
i = i + 1
in the value part...use "rec"
but after I sort on LatLong and run the script, the labels appear to be generated in an order that is linked to the FID - which is just random.
Do I need to re-order the FIDs somehow so that the labels will appear consecutive based on Lat/Long?? Can I mess with the FID? Or do you know of a better solution?
any ideas? thanks
Mapping Center Answer:
We have attached a Python script you can use to do what you are asking about. To use it, in ArcMap open ArcToolbox, right click in the toolbox and click New Toolset. Then right click the new toolset and click Add then Script. Fill in the first page, click next and on the second page browse to the location of the attached zip file that you downloaded. Right click the script and click Edit. Here you have to make three changes:
- On the line that starts with "fc = r"C:\...", change the path to the location of your geodatabase (replace "C:\MC\rnd\test.mdb\") and the name to your feature class (replace "point")
- On the line that starts with "fcWrite = gp.updatecursor...", change "lat" to the field name on which sorting is required in descending order in the attribute table for your data
- On that same line change "id" to the field name in the attribute table for your data that will be updated starting with 1 based on "lat"
If you would like to post a comment, please login.