I've no idea if this is basic or what but I have this data that contains multiple lines (forming a polygon shape). I want to convert those lines (multiple – each with a start and end point) to a single line. I tried dissolve, multipart to single part etc. I cannot use topology since it influences precision. I have zero knowledge of programming.
[GIS] Converting multiple lines into single line using ArcGIS Desktop
arcgis-desktoplinepolygon
Related Solutions
I've devised a way of doing it with little bits from all of the other answers.
The scripts that @GeoJohn and @FelixIP have created may well work (if you have access to ArcGIS 10.1 and the database access functions), so if someone else had this problem please check those options out as well.
I did the following in the end:
Created a very small buffer polygon around the lines (0.1 metres) to make sure there was crossover between the lines that were connected.
Use the dissolve tool with the Unsplit option checked. This created individual polygons for each of the connected line groups.
Create a unique ID for each polygon.
Use the spatial join tool to add the unique polygon ids to each line that intersects or is within the polygons.
Use the dissolve tool again to dissolve the lines based on the unique ID.
That has worked for me but like I said the scripting methods may be preferable for other people.
Following the above advice by @StevenKay this small experiment worked for me. Please note this is tested on 1 set of line segments.
Overall this goes like this:
- Join line segments into one line by
Join Multiple Lines
. This sorts the order and direction of segments. - Split the line again into segments. (
Explode lines
) - Look up the id field of the original line segments (
refFunctions
) - Join attribute tables, using the
id
fields.
First, I have this collection of random line segments
By Join Multiple Lines
plugin, segments are combined into single line. Most importantly it becomes continuous and orderly (see comments by Steven Kay). At the same time attribute table loses rows except for the first one.
Then I split the line by Explode lines
in the processing toolbox.
As I already have refFunctions plugin, just opened the attribute table of Exploded
and created a new field "original" by expression geomequals('original_lines', 'id')
.
Above picture looks exactly same as the original random line segments. Their difference is only the order of segments.
Now I can Join
the attribute table of original layer and this sorted layer, to get the final product.
Best Answer
Try dissolving based off of OBJECTID or FID. Then use Feature To Polygon (Data Management) to convert your polylines to polygons if you wish. To illustrate, here are some sample lines:
Attribute table before dissolve by OBJECTID
Attribute table after dissolve by OBJECTID