Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a number of polylines (around 9000), a number of which have one or both ends touching another polyline. I would like to merge these ones together into one polyline - thus reducing the number of polylines and ensuring that each line represents one real-world object (rather than having multiple lines per object).

I cannot find a scriptable (preferably through a Python script) way to do this. Is this possible? It would seem to me like a fairly common operation to want to do, but I can't seem to find a built-in function.

share|improve this question
up vote 7 down vote accepted

Try the Dissolve tool with the UNSPLIT_LINES option.

Aggregates features based on specified attributes.

...

  • The Unsplit lines parameter with two options, DISSOLVE_LINES and UNSPLIT_LINES, only applies to line input. When the default DISSOLVE_LINES option is specified, lines are dissolved into a single feature. When UNSPLIT_LINES is specified, only two lines that have a common endpoint (known as pseudonode) are merged into one continuous line.
share|improve this answer
    
I was about to recommend this, here is the python equivalent in 9.3.1 and will need to be adjusted to either run in v10 or outside of the ArcGIS python/command line window. Dissolve_management("Road","C:/gis/data/temp/road_d.shp","Road_Name","SHAPE.len SUM","MULTI_PART","UNSPLIT_LINES") – SaultDon Jan 19 '11 at 16:06

Haven't tested it but should work nonetheless.

IFeature polyline, polyline2;
ITopologicalOperator op = polyline.Shape as ITopologicalOperator;
polyline.Shape = op.Union(polyline2);

See AO-API.

share|improve this answer
    
Sounds great. I'll have to have a look at the ArcObjects API, I haven't used it before. Do you know if there is an equivalent operation I can do in Python? – robintw Jan 19 '11 at 14:02
    
@robintw I think you should be able to use the code provided and create a toolbox. Then that toolbox can be called from the modelbuilder. – Brad Nesom Jan 19 '11 at 14:41

if your ArcGIS comes with Data Interoperability extention, LineJoiner transformer is able to do your task. BTW, Data Interoperability is built from FME, you can see how that transformer works here: http://www.fmepedia.com/index.php/LineJoiner

share|improve this answer

I found that the basic dissolve tool works much better than the multipart-->singlepart then unsplit lines approach.

share|improve this answer
1  
Hi Pat, Welcome to GIS.se :) One line answers are discouraged. The meat of the Q is about a scriptable method for joining, you could improve your answer by expanding on how basic dissolve addresses this, as well as perhaps explaining why or how dissolve works better for this job in your experience. – matt wilkie May 17 '13 at 20:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.