1

I am trying to produce a map in ArcGIS 10.1 that symbolizes by feature class but also assigns a unique number (as part of the symbol) to each location that will relate to a table embedded in the map that has more detailed descriptions for each location (i.e. location name, address, etc.). My current map (below) has unique symbols for monitoring wells, endangered species, churches, schools, daycares, etc., but it doesn't leave any place for a unique value per location (starting at 1, then 2, 3, etc.).

Would it be possible to create a custom symbol with a unique color (e.g. blue in-filled circle for hotels) for each feature class and then have it automatically assign a consecutive, unique number in the center for each location? An easy out would be to keep the symbology I have and just have number labels for each location. I was just hoping to avoid having to place labels at each location. If the solution requires heavy scripting, then I may not have the skills to do it. Thanks.

enter image description here Example symbol I would like:

enter image description here

Example table key I would like embedded in the map somewhere: enter image description here

4
  • 1
    FID/OBJECTIDs are unique, why not use them? Note that FIDs in shapefiles are only static until you start editing then they change. Aug 22, 2014 at 3:46
  • I thought about using the FID, but the problem is the FID/Object IDs aren't consecutive within the map extents I am interested in. I could just add a new field and assign my own numbers, but then how do I auto-output that into the custom symbol?
    – Dre
    Aug 22, 2014 at 12:36
  • 1
    It's not too difficult to do in python with an update cursor, just keep multiple iterators and assign and increment for each match, is that something that would interest you? Aug 24, 2014 at 21:43
  • @MichaelMiles-Stimson I ended up assigning my own unique IDs in a new field for points in my map extent and adding them over my feature class symbols as labels, then converting them to annotation. However, I had to do this for each feature class individually, so it was a bit tedious. I would still be interested in a python solution.
    – Dre
    Aug 31, 2014 at 22:16

1 Answer 1

1

Here's a quick script I've thrown together.. it assumes that all the data is in one feature class though it wouldn't be much to modify it to accomodate counting over multiple feature classes.

import os, sys, arcpy

IndexField = "RefID"     # name of field to calculate
ValueField = "Category"  # name of field to base classes on

InFC = sys.argv[1]   # the feature class to calculate

UValList  = list()  # empty lists to store values and indicies
UIndxList = list()

# make a list of the fields, order is important!
FList = list()
FList.append(IndexField)
FList.append(ValueField)

with arcpy.da.UpdateCursor(InFC,FList) as UpCur:
    for UpRow in UpCur:
        if len(UValList) == 0:
            UValList.append(UpRow[1]) # insert the first value!
            UpRow[0] = 1              # set the first counter to 1
            UIndxList.append(1)       # store the first value
        else:
            ValueFound = False         # assume the value is not found
            Ctr = range(len(UValList)) # set up a range to use as a counter
            for Indx in Ctr:           # step through the counter
                # lower case comparison of values
                #if UpRow[1].lower() == UValList[Indx].lower():

                # Numerical or case sensitive comparison
                if UpRow[1] == UValList[Indx]:
                    ValueFound = True
                    UIndxList[Indx] += 1 # increment the value
                    UpRow[0] = UIndxList[Indx]
                    break # exit the loop
            if not ValueFound:
                # first one of a new value
                UValList.append(UpRow[1]) # insert the first value!
                UpRow[0] = 1              # set the first counter to 1
                UIndxList.append(1)       # store the first value
        UpCur.updateRow(UpRow) # update the row

There is no error checking in this script to keep it as simple as possible. For your data you will have to change the values for IndexField and ValueField to suit your data. In this case the IndexField is the name of the field that will be overwritten with the unique index and the ValueField is the unique values to increment over.. in the script the condition for matching values to existing values is case sensitive or numeric, I've included a line to show how to match case insensitive - don't use that for numbers or you'll get an error like AttributeError: 'int' object has no attribute 'lower'.

The way it works (in pseudo code):

  • for the first value add the value to a list and also the number 1 to another list
  • for each subsequent value try to find the value in the list:
  • if found, increment the matching number and assign it to the feature
  • if not found add a new entry (value and 1) to both lists
  • update the feature

Here is a link to show you how to put this into a toolbox and run it from catalog or map http://resources.arcgis.com/en/help/main/10.2/index.html#//00150000001r000000.

I hope this helps point you in the right direction. If you are confused about any of it let me know and I'll try to explain.

2
  • Thank you for taking the time to write this script even though it is above my skill level. Some questions: 1) What would my ValueField be? I am just assigning consecutive numbers to each point in my feature class that appears in my map extent and I don't think I would be using existing unique values to increment over. 2) Would this script be complicated by the fact that I may have overlapping map extents? That is, some points may have more than one value assigned because they appear in two different maps.
    – Dre
    Sep 1, 2014 at 3:08
  • 1
    ValueField is the field that exists in the data containing the classes that you want to number, if they all belong to different feature classes you will have to ensure the field name matches the feature class or merge the features into one feature class. Yes, the numbering is for the whole feature class, if you only want to number what's on the map then extract it to a feature class for the map area. Sep 1, 2014 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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