Merge lines within threshold from Python

341
3
01-19-2011 05:51 AM
RobinWilson
New Contributor
I have a shapefile with a lot (around 9000) line features in it. Many of these line features are either touching, or very close to touching, and I would like to merge these ones into one feature. Ideally I would then end up with a shapefile with around 50 features in it, each of which would have been merged from the features that were touching.

How should I do this from python? I know I can do it manually from the editor toolbar with the merge tool, but I can't seem to find how to do this programmatically. I've searched in various places and can't seem to find an answer.

Does anyone have any ideas?
Tags (2)
0 Kudos
3 Replies
NiklasNorrthon
Occasional Contributor III
Maybe the Unsplit Line or the Dissolve tool is what you are looking for.
0 Kudos
ChrisSnyder
Regular Contributor III
The Integrate tool?
0 Kudos
RobinWilson
New Contributor
Thanks - that looks great.

Is there any difference between the Unsplit Lines tool and the Dissolve tool with the Unsplit Lines checkbox ticked? It doesn't look like there is, but I thought I'd check.

Also, does anyone know a way to do this with distance tolerances too (that is, merging lines that are within a certain distance of another line, instead of having to touch the line).
0 Kudos