0

My python code :

import arcpy

arcpy.FeatureToLine_management("Closestroute", "Featureline", "0.0001 Meters", "ATTRIBUTES")

#Generate points along lines for every 1 km

arcpy.GeneratePointsAlongLines_management("Featureline", "splitPoints", "DISTANCE", "1000 Meters", "", "NO_END_POINTS")

#Split line at point for every 1 km roads,search radius = 20 meters

arcpy.SplitLineAtPoint_management("Featureline", "splitPoints", "split1kpoints", "20 Meters")

#I added SS field into splitPoints, then I assigned name for each rows.(s1, s2, s3, ...) 

cursor=arcpy.da.UpdateCursor("splitPoints","SS")

i = 0

for row in cursor:

row[0] = 's' + str(i)

i += 1

cursor.updateRow(row)

del row

del cursor

My problem is:

I am trying to assign one name for each points. However, when one route are used by more than one start points like blue arrow in the picture below, I obtained more than one segments name for this route. I am trying to get just one segments name for each points for this route. (showed with blue arrow) for both start points.

How I can deal with this problem ?

enter image description here

  • 1
    Please format your code legibly by using the original code and the {} format button. – Vince Dec 28 '18 at 18:09
  • With the DA cursor, can you check if the Name is blank, then populate? – klewis Dec 28 '18 at 18:29
3

It looks like points are stacking up due to duplicate line features or line feature segments. I'd perform a delete identical on your output point feature class, either before or after your cursor.

shpFld = arcpy.Describe ("splitPoints").shapeFieldName
arcpy.DeleteIdentical_management ("splitPoints", shpFld)
  • Thank you so much ! This helps a lot !! Since I am assigning name in order, although one segment is used by two shortest paths, in attribute table, shows for just one start-end point shortest path. I have posted my guestion. If you can take a look, I will be appreciated for that. @Emil Brundage – Aera Dec 28 '18 at 21:00

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.