Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. ## create anchor points at intersections
  2. arcpy.Intersect_analysis("LINES", "D:/Scratch/mpoints.shp","ALL", "POINT")
  3. arcpy.MultipartToSinglepart_management("mpoints","D:/Scratch/anchors.shp")
  4. arcpy.DeleteIdentical_management("anchors","Shape")
  5. # calculate their distance along the line
  6. arcpy.AddField_management("anchors", "CHAINAGE", "DOUBLE")
  7.  
  8. def Chainage(shp):
  9. mxd = arcpy.mapping.MapDocument("CURRENT")
  10. lr=arcpy.mapping.ListLayers(mxd,"lines")[0]
  11. with arcpy.da.SearchCursor(lr, 'Shape@') as cursor:
  12. for row in cursor: geom=row[0]
  13. L=geom.measureOnLine (shp.firstPoint)
  14. return int(L)
  15. #-------------------------
  16. Chainage(!Shape! )
  17.  
  18. #sort anchor points accordingly
  19. arcpy.Sort_management("anchors","D:/Scratch/sorted.shp", "CHAINAGE ASCENDING")
  20.  
  21. # Place ‘equally’ space points on BLUE line
  22. arcpy.CalibrateRoutes_lr("LINES", "Name", "sorted", "Name", "CHAINAGE","D:/Scratch/routes.shp")
  23. arcpy.MakeRouteEventLayer_lr("routes", "Name", "from_Excel", "LINE POINT m", "BLUE_POINTS", point_event_type="POINT")
  24. # create cross-lines
  25. arcpy.Merge_management("RED_POINTS;BLUE_POINTS", "D:/Scratch/merged.shp")
  26. arcpy.PointsToLine_management("merged", "D:/Scratch/grey_sections.shp", Line_Field="M")
  27. # compute their mid points and draw the line
  28. arcpy.FeatureVerticesToPoints_management(“grey_sections", “D:/Scratch/mid_points.shp", "MID")
  29. arcpy.PointsToLine_management("mid_points", "..Green_Line.shp", Sort_Field="M")
  30.  
  31. # create cross-lines
  32. arcpy.Merge_management("RED_POINTS;BLUE_POINTS", "D:/Scratch/merged.shp")
  33. arcpy.PointsToLine_management("merged", "D:/Scratch/grey_sections.shp", Line_Field="M")
  34. # compute their mid points and draw the line
  35. arcpy.FeatureVerticesToPoints_management(“grey_sections", “D:/Scratch/mid_points.shp", "MID")
  36. arcpy.PointsToLine_management("mid_points", "..Green_Line.shp", Sort_Field="M")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement