Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## create anchor points at intersections
- arcpy.Intersect_analysis("LINES", "D:/Scratch/mpoints.shp","ALL", "POINT")
- arcpy.MultipartToSinglepart_management("mpoints","D:/Scratch/anchors.shp")
- arcpy.DeleteIdentical_management("anchors","Shape")
- # calculate their distance along the line
- arcpy.AddField_management("anchors", "CHAINAGE", "DOUBLE")
- def Chainage(shp):
- mxd = arcpy.mapping.MapDocument("CURRENT")
- lr=arcpy.mapping.ListLayers(mxd,"lines")[0]
- with arcpy.da.SearchCursor(lr, 'Shape@') as cursor:
- for row in cursor: geom=row[0]
- L=geom.measureOnLine (shp.firstPoint)
- return int(L)
- #-------------------------
- Chainage(!Shape! )
- #sort anchor points accordingly
- arcpy.Sort_management("anchors","D:/Scratch/sorted.shp", "CHAINAGE ASCENDING")
- # Place ‘equally’ space points on BLUE line
- arcpy.CalibrateRoutes_lr("LINES", "Name", "sorted", "Name", "CHAINAGE","D:/Scratch/routes.shp")
- arcpy.MakeRouteEventLayer_lr("routes", "Name", "from_Excel", "LINE POINT m", "BLUE_POINTS", point_event_type="POINT")
- # create cross-lines
- arcpy.Merge_management("RED_POINTS;BLUE_POINTS", "D:/Scratch/merged.shp")
- arcpy.PointsToLine_management("merged", "D:/Scratch/grey_sections.shp", Line_Field="M")
- # compute their mid points and draw the line
- arcpy.FeatureVerticesToPoints_management(“grey_sections", “D:/Scratch/mid_points.shp", "MID")
- arcpy.PointsToLine_management("mid_points", "..Green_Line.shp", Sort_Field="M")
- # create cross-lines
- arcpy.Merge_management("RED_POINTS;BLUE_POINTS", "D:/Scratch/merged.shp")
- arcpy.PointsToLine_management("merged", "D:/Scratch/grey_sections.shp", Line_Field="M")
- # compute their mid points and draw the line
- arcpy.FeatureVerticesToPoints_management(“grey_sections", “D:/Scratch/mid_points.shp", "MID")
- arcpy.PointsToLine_management("mid_points", "..Green_Line.shp", Sort_Field="M")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement