Select to view content in your preferred language

Feature to Line on feature selections with ArcPy

1096
2
Jump to solution
05-24-2013 01:39 AM
RobinEdwards
New Contributor
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.

Grateful for any advice from high ArcPy wizards on how best to approach this. I'm pretty new to ArcPy so any advice on e.g. creating temporary layers to work with would be very helpful. As a starting point please just assume a polylines shapefile. The planned workflow is to rejoin these with the other road data once they've been collapsed. Many thanks in advance.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
markdenil
Frequent Contributor
Your answer is mentioned in your post. Passing a layer created with a definition query will provide subsets of the source data. You can then merge the outputs from each itteration.

To make the subsets
Attribute your source data with an id indicating which subset it should be processed in
using, say, a field called FIELD
and identifing features in, say, four groups identifed by letters.
theList = ['a', 'b', 'c', 'd'] for each in theList:     defQuery = "\"FIELD\" = '%s'" % (each)     print defQuery

continue the loop by
passing the defQuery to CreateFeatureLayer
then pass the feature layer to the tool you want (Feature To Line, it seems).
then delete the layer and continue by looping to the next letter in for loop.

View solution in original post

0 Kudos
2 Replies
markdenil
Frequent Contributor
Your answer is mentioned in your post. Passing a layer created with a definition query will provide subsets of the source data. You can then merge the outputs from each itteration.

To make the subsets
Attribute your source data with an id indicating which subset it should be processed in
using, say, a field called FIELD
and identifing features in, say, four groups identifed by letters.
theList = ['a', 'b', 'c', 'd'] for each in theList:     defQuery = "\"FIELD\" = '%s'" % (each)     print defQuery

continue the loop by
passing the defQuery to CreateFeatureLayer
then pass the feature layer to the tool you want (Feature To Line, it seems).
then delete the layer and continue by looping to the next letter in for loop.
0 Kudos
RobinEdwards
New Contributor
Spot on! Thank you Mark.
0 Kudos