0

I'm trying to collapse parallel polylines (dual carriageways in a shapefile of roads) to single centrelines. I'm aware of cartography's dual lines to centerline tool, but I find Feature To Line (Data Management) slightly more reliable. The challenge is that whichever function is used requires a large tolerance (e.g. 10m+) so must be applied to custom selections of data in order to avoid creating new artifacts between unrelated pairs - hence the need for custom selections, which as far as I can tell these functions can't handle.

I'm pretty new to ArcPy so advice on creating temporary layers to work with would be very helpful. As a starting point just assume a polylines shapefile. The planned workflow is to rejoin these with the other road data once they've been collapsed.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked May 22, 2013 at 15:00
0

1 Answer 1

0

Perhaps not the most elegant solution (based on advice from ArcGIS Forums), but it works for me:

fieldNames = getValueList("shapefile", "FIELD")
fieldNames = map(str, fieldNames)
# blank layer for results called 'merged'
arcpy.CreateFeatureclass_management("C:\\PATH", "merged.shp", "POLYLINE", "shapefile.shp", "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", "shapefile.shp")
for each in fieldNames:
 defQuery = "\"FIELD\" = '%s'" % (each)
 # create temporary layer of DCs with same official road identifier
 arcpy.MakeFeatureLayer_management("shapefile", "selectn", defQuery)
 # run centre-line function on the selection and assign to new layer
 arcpy.FeatureToLine_management("selectn", "newSelectn", "20.0 Meters", "ATTRIBUTES")
 arcpy.Append_management("newSelectn", "merged", "NO_TEST")
 arcpy.Delete_management("newSelectn.shp")
 arcpy.Delete_management('selectn')
answered May 24, 2013 at 15:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.