I have a highway layer that I need to style in ArcMap in such a way to differentiate between individual highway sections, ideally using no more than 6-7 distinct colors. Each highway is divided into one or more sections. Highways have Road Number and Section Number attributes that I can use for styling. The symbology will need to be exportable to ArcPad. I can calculate/add new fields to the table, if that helps.

Here's an image of how a section of highway may look like:

enter image description here

Note that in the image, the colors aren't repeated, but they will definitely have to be over the entire highway network. All I'm looking to accomplish is show highway section breaks with a limited subset of colors.

  • You could write a Python (or similar) script which iterates through each line segment and assigns it a colour. The pseudo code could be something like: (1) get the line. (2) check if it has a colour - if not give it colour n, and increment n. (3) find its neighbouring line. (4) check if it has a colour - if not give it colour n, and increment n. (5) get the next line, etc. This would need to be iterative, with potentially multiple passes over the network to ensure neighouring segments didn't share a color. – Stephen Lead Jun 17 '11 at 0:58
  • What is the max number of section in any given highway? Is there a limit, if at all? – ujjwalesri Jun 17 '11 at 6:42
  • @slead: That was my initial thought, but it is very inefficient and potentially slow on large layers. @ujjwalesri: Theoretically there is no upper limit to the number of sections. Currently, the highest number of sections is 82, but that could change. – Sasa Ivetic Jun 17 '11 at 12:47
  • 1
    QGIS has a plugin called "TopoColor" which allows the user to choose an attribute and the plugin will make an assessment of the data and determine the minimum # of colors needed to not have any polygons features touching another. If you feel like digging into the code, you might be able to port the concept to ArcMap. – RyanKDalton Jun 17 '11 at 20:04
  • 1
    +1 interesting question. I wonder if this could be thought of as a four color map problem for vectors. Are your highways in a geometric network? – Kirk Kuykendall Jun 22 '11 at 15:29

In ArcMap go to the menu Customize -> Style Manager.

In your personal style (or whatever works for you) click on Color Ramps. In the area to the right, right-click New -> Preset Color Ramp...

Change the colors to what you want. If you only want 6 or 7 colors you'll have to repeat colors.

Use this ramp to symbolize the highway segments.

This will get you the same effect if in a hackish kind of way.

  • Thanks for the answer, however trying to do this for 1600 features is simply not feasible. – Sasa Ivetic Jun 20 '11 at 14:24
  • @Sasa Why is it not feasible? Any solution you choose is going to have to symbolize each of the 16,000 segments individually. Whether you do it programmatically or by category with a ramp like I suggest. To clarify, I'm suggesting you symbolize by category using each segments ID as the category. The problem you'll face is that it might symbolize two touch segments with the same color. – Sean Jun 20 '11 at 14:38

I hacked together a quick script yesterday to add a category to each highway section based on the sections it intersects. The script will automatically decide what the max number of categories is as it goes along. Its not necessarily the most efficient/clean method, but I didn't any more free time to look into it. I'm also fairly new at python/arcpy, so the code could use a bit of cleanup:

import arcpy
from arcpy import env

# Set the workspace
env.workspace = "C:/Projects/Misc/HighwaySymbology"

# Create a copy of the highways shapefile
arcpy.CopyFeatures_management("highways.shp", "highways_out.shp")

# Add a category field
arcpy.AddField_management("highways_out.shp", "hwycat", "LONG", 9)

# Create a feature layer
fl = arcpy.MakeFeatureLayer_management("highways_out.shp", "Highways")

# Create the update cursor
rows = arcpy.UpdateCursor("highways_out.shp")

# Create the in-memory layer to select with
arcpy.MakeFeatureLayer_management("highways_out.shp", "HwySelection")

# Loop through every highway segment, one by one
for row in rows:
    arcpy.SelectLayerByAttribute_management("HwySelection", "NEW_SELECTION", "FID = " + str(row.FID))

    arcpy.SelectLayerByLocation_management("Highways", "INTERSECT", "HwySelection", "", "NEW_SELECTION")
    numSelHwys = int(arcpy.GetCount_management("Highways").getOutput(0))

    # Number of selected highways should always be > 1, 
    # as it will at least select the current highway
    if numSelHwys > 1:
        # Loop through all sections of the road and find the
        # lowest unused highway category
        selHwys = arcpy.SearchCursor("Highways")

        hwyCategories = []
        for selHwyRow in selHwys:
            # Skip the current highway
            if selHwyRow.FID == row.FID:

            if selHwyRow.hwycat > 0:

        # Sort the list and find the first available category
        lastCat = 0
        for cat in hwyCategories[:]:
            if cat - lastCat > 1:
                lastCat = cat

        lastCat += 1
        row.hwycat = lastCat

        # No adjoining segments, set the category to 1
        row.hwycat = 1

print "DONE"

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.