0

I want to name the features in a featureclass in ascending order alphabetically. I have a line with a direction and I want the one closest to the start to be A, the next closest B etc. When I get to a new line, I want it to start from A again.

I have tried to use the GP tool locate features along route, but it does not generate any output. Im using ArcMap 10.5, but have access to ArcGIS Pro as well.

Naming of features.

  • Please Edit the question to expand upon "does not seem to work." Exact usage, error messages, and any other useful information is needed. Is the image an example of actual output or what is desired? – Vince Dec 20 '18 at 13:13
  • You want the polygons to get the ABCDE.. attributes? – BERA Dec 20 '18 at 14:06
  • @BERA Yes, that is correct. I have a text field for the letters. – birks Dec 20 '18 at 14:10
  • 1
    Assuming the line is in a Route Feature Class with measure coordinates, the output of the Locate Features Along Route tool is an event table, not a feature class. Before using the tool you should add a Long field to the overlapping FC and calculate the OBJECTID into it so it will be preserved in the event table. Create a line event table output with a route name field and two measure fields. Sort these fields to put the records in order along the line. Then assign letters manually or using a custom script. Then Join the FC OID to the table long field and calc the values over to the FC. – Richard Fairhurst Dec 20 '18 at 16:30
  • 2
    @RichardFairhurst I used your answer, so if you want to post it as an answer I will mark as the answer. – birks Dec 21 '18 at 12:41
1

Assuming the line is in a Route Feature Class with measure coordinates, the output of the Locate Features Along Route tool is an event table, not a feature class. Before using the tool you should add a Long field to the overlapping FC and calculate the OBJECTID into it so it will be preserved in the event table. Create a line event table output with a route name field and two measure fields. Sort these fields to put the records in order along the line. Then assign letters manually or using a custom script. Then Join the FC OBJECTID to the table long field and calc the values over to the FC.

1

You can use arcpy. Code below is moving a point along each line and for each jump checks which polygon lies beneath it and gives it a letter. When one line ends the lettering starts over.

import arcpy, string

arcpy.env.workspace = r'C:\Default.gdb' #Change
polygons = 'polysalongline' #Change
line = 'letterline' #Change
polyfield_to_update = 'Letter' #Change
jump = 5 #Adjust to smaller value than the thinnest part of any polygon that is crossed by the line. I use 5 meters

lines = [i[0] for i in arcpy.da.SearchCursor(line,'SHAPE@')]
polys = [i for i in arcpy.da.SearchCursor(polygons,['SHAPE@','OID@'])]
d={}

for line in lines:
    letter = 0
    position = 0
    while position < line.length:
        for p in polys:
            if line.positionAlongLine(position).within(p[0]) and p[1] not in d:
                d[p[1]]=string.ascii_uppercase[letter]
                letter+=1
        position+=jump

with arcpy.da.UpdateCursor(polygons,['OID@',polyfield_to_update]) as cursor:
    for row in cursor:
        if row[0] in d:
            row[1]=d[row[0]]
            cursor.updateRow(row)

enter image description here

  • 1
    Thank you very much for this. I did not know about the positionAlongLine function. It is almost perfect, but it will leave out those features which are not directly under the line. I might have missed it in my example, but there are some features that does not connect to the line, like the one to the right of your C. – birks Dec 21 '18 at 8:15

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.