Merging line-features from 2 different layers

3200
7
Jump to solution
05-12-2013 01:11 PM
wolfgangobruca
New Contributor
Hi,

Im struggling a lot with the following issue:

I got one shapefile which shows main rivers (those rivers again are segmented into several parts by an ID); as well as one shapefile with the corresponding tributaries to those main rivers.
My task is to merge the tributaries to the main rivers in such way that the endproduct will be a total river network. The idea then is to get a combined polyline for every main river segment and the tributaries belonging to it, i.e. the number of main river segments is just the same as before, it is only that now each main river segment should be extended by tributaries.
I did already some attempts on spatial joining the tributaries to the main rivers (join many to one), which works, but I the layout view is still lacking of tributaries.
Other attempts like "union" did not work either, because they require polygon shapefiles.
The dissolve tool again needs to be fed with only one shapefile, which is not the case here. And finally, merging is not leading to the desired goal, because it constructs two distinct data sets in the attribute table rather than assigning the tributaries to the segments.

Any suggestions or solutions for this?

I hope anyone out there in the Esri forum knows how to resolve my tricky problem;)
Many thanks in advance,
Greetings, Wolfgang O (Austria)
0 Kudos
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor
Ok guys, i just see i got some very comprehensive answers, thanks for that. But i got to confess I was only telling you the half of the truth. So may I can ask you how you would solve this task:

[ATTACH=CONFIG]0[/ATTACH]

Actually it is not about creating a whole drainage network as one, but to set up so-called "habitat patches" for fish. The red line is a main river stretch  and the blue line represents a part from a tributary (as mentioned in my first thread, tributaries and the main segment are  2 different shpfiles. The grey points are impassable barriers for fish, so shortly speaking, every habitat is representing an area that delineates a freely moveable river habitat which will end at any impassable barrier.
OK so now how would you create a single habitat patch (uniform ID) consisting of tributary (blue) and main stretch(red) out of the two different shapefiles.

Please be so kind to describe it in a manner so that an arcgis newcomer such as me will be able to reproduce it.
Many thanks for your answers so far. I can see whether I am able to solve this problem with your information already provided. I will let you know if it works.
Thanks, Wolf


Well that is a more complicated problem.  Ultimately you want the original line sets merged into one file, and in addition to remaining split at the rivers and tributaries, you want them divided at the barriers.  So here is the workflow I would try:

1. Add a field to store an attribute distinguishing the two line types (create that field on the main rivers first and assign it a value meaning rivers and then merge the tributaries in and select the null values or 0 values for that field and calculate a value representing the tributaries).

2.  Merge the two line sets together with the merge tool as mentioned and do the necessary tributary attribute selection and attribute calculation.

3.  You may want to make sure your lines have true connectivity, and might (on a copy of your merged file) use the Integrate tool to get snapping of lines to occur. 

4. Use the Split Line at Points tool to break your lines using the barrier points (requires an Advance license).  If you do not have an advanced license, then you would need to break the lines some other way at the barriers.  I came come up with an alternative to that tool given time, but it is not an easy tool to replace.

5.  Run the Buffer tool with a small buffer to generate polygons around your lines.

6. Do Dissolve on these buffers using the single part feature option (This would not work for dissolving branching lines into one feature, but does work for merging branching polygons into one feature).

7. Now do a buffer that is only slightly larger than the one you did for your lines on the barrier points.

8. Use the Union Tool on the line buffers and point buffers.  http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000000s000000

9. Select by Attribute and delete all polygons in the Union where the FID of the point buffers is greater than -1 and delete them.

10. Use the Multi-part to Single-Part tool to make sure the buffers are separated at the boundary point locations. 

11. Use the Spatial Join tool using the One-To-Many option on the lines that were split using the Split at Points tool at step 4.

Now you should have lines that have a buffer FID that ensures those lines could all be connected together without crossing a barrier (regardless of whether they were a tributary or river).  The buffer FID represents your habitat patch ID value that associates all lines that have the same habitat patch accessibility level for your fish.  Additionally these lines still can be colored separately as rivers or tributaries based on the attribute you added at step 1.

If you want to Dissolve the lines into a single line feature (with no distinction in rivers and tributaries) use the Dissolve tool or Create Route tool on just the Buffer FID field value.  If you want rivers dissolved separately from tributaries use the Dissolve tool on the habitat patch buffer FID and the attribute you added at step 1.  Or create a text field and concatenate these two values together as a Route ID for the Create Route Feature tool.  Any of these dissolves or routes will lose any river names of the original lines and will only be useful for making it easier to select these habitat patches.

View solution in original post

0 Kudos
7 Replies
RichardFairhurst
MVP Honored Contributor
Hi,

Im struggling a lot with the following issue:

I got one shapefile which shows main rivers (those rivers again are segmented into several parts by an ID); as well as one shapefile with the corresponding tributaries to those main rivers.
My task is to merge the tributaries to the main rivers in such way that the endproduct will be a total river network. The idea then is to get a combined polyline for every main river segment and the tributaries belonging to it, i.e. the number of main river segments is just the same as before, it is only that now each main river segment should be extended by tributaries.
I did already some attempts on spatial joining the tributaries to the main rivers (join many to one), which works, but I the layout view is still lacking of tributaries.
Other attempts like "union" did not work either, because they require polygon shapefiles.
The dissolve tool again needs to be fed with only one shapefile, which is not the case here. And finally, merging is not leading to the desired goal, because it constructs two distinct data sets in the attribute table rather than assigning the tributaries to the segments.

Any suggestions or solutions for this?

I hope anyone out there in the Esri forum knows how to resolve my tricky problem;)
Many thanks in advance,
Greetings, Wolfgang O (Austria)


What is wrong with Merge and then Dissolve?  That should do the trick.  If an attribute needs to transfer to the tributaries first, then do Spatial Join, Merge and Dissolve.  Geoprocessing is all about adding tools together in the correct order, not waiting for someone to design a single tool that does everything at once.
0 Kudos
markdenil
Occasional Contributor III
As I read your post, what you are wanting to do is create a single feature with branching lines:
a river and tributaries forming a drainage network.
That is simply not possible with simple line features: lines don't fork.

You need to create routes, based on a common feature attribute.
Something like "basinName", that will identify all the segments and tributaries that make up a particular
"combined polyline for every main river segment and the tributaries belonging to it".

To Wit: whatever the actual river or tributary name, all the lines that connect flowing northwest have
basinName = 'Rhine' and the ones that connect up flowing southeast have basinName = 'Danube'

Use the Create Routes tool in the Linear Referencing toolbox.

This will give you a forking line feature named Rhine and one named Danube.
0 Kudos
RichardFairhurst
MVP Honored Contributor
As I read your post, what you are wanting to do is create a single feature with branching lines:
a river and tributaries forming a drainage network.
That is simply not possible with simple line features: lines don't fork.

You need to create routes, based on a common feature attribute.
Something like "basinName", that will identify all the segments and tributaries that make up a particular
"combined polyline for every main river segment and the tributaries belonging to it".

To Wit: whatever the actual river or tributary name, all the lines that connect flowing northwest have
basinName = 'Rhine' and the ones that connect up flowing southeast have basinName = 'Danube'

Use the Create Routes tool in the Linear Referencing toolbox.

This will give you a forking line feature named Rhine and one named Danube.


I do concur that Linear Referencing is probably the best approach for the step where you dissolve the lines.  You still need to do the common attribute on all lines (using Spatial Join if necessary) and the merge of the lines into a single feature class to use the Make Route Feature tool.  Also, it is not entirely true that simple polyline networks cannot handle this without using Linear Referencing, since you can create multi-part lines in a polyline feature class.  Also, in reality routes are simple polyline feature classes that permit multi-line polylines themselves.  Except that linear referenced routes have the added benefit of applying measures to your polylines that allow you to station events on your river network when the measures are built to follow the flow of the river network.  So do look at the Make Route Feature tool in the place of the Dissolve tool.
0 Kudos
wolfgangobruca
New Contributor
Ok guys, i just see i got some very comprehensive answers, thanks for that. But i got to confess I was only telling you the half of the truth. So may I can ask you how you would solve this task:

[ATTACH=CONFIG]0[/ATTACH]

Actually it is not about creating a whole drainage network as one, but to set up so-called "habitat patches" for fish. The red line is a main river stretch  and the blue line represents a part from a tributary (as mentioned in my first thread, tributaries and the main segment are  2 different shpfiles. The grey points are impassable barriers for fish, so shortly speaking, every habitat is representing an area that delineates a freely moveable river habitat which will end at any impassable barrier.
OK so now how would you create a single habitat patch (uniform ID) consisting of tributary (blue) and main stretch(red) out of the two different shapefiles.

Please be so kind to describe it in a manner so that an arcgis newcomer such as me will be able to reproduce it.
Many thanks for your answers so far. I can see whether I am able to solve this problem with your information already provided. I will let you know if it works.
Thanks, Wolf
0 Kudos
RichardFairhurst
MVP Honored Contributor
Ok guys, i just see i got some very comprehensive answers, thanks for that. But i got to confess I was only telling you the half of the truth. So may I can ask you how you would solve this task:

[ATTACH=CONFIG]0[/ATTACH]

Actually it is not about creating a whole drainage network as one, but to set up so-called "habitat patches" for fish. The red line is a main river stretch  and the blue line represents a part from a tributary (as mentioned in my first thread, tributaries and the main segment are  2 different shpfiles. The grey points are impassable barriers for fish, so shortly speaking, every habitat is representing an area that delineates a freely moveable river habitat which will end at any impassable barrier.
OK so now how would you create a single habitat patch (uniform ID) consisting of tributary (blue) and main stretch(red) out of the two different shapefiles.

Please be so kind to describe it in a manner so that an arcgis newcomer such as me will be able to reproduce it.
Many thanks for your answers so far. I can see whether I am able to solve this problem with your information already provided. I will let you know if it works.
Thanks, Wolf


Well that is a more complicated problem.  Ultimately you want the original line sets merged into one file, and in addition to remaining split at the rivers and tributaries, you want them divided at the barriers.  So here is the workflow I would try:

1. Add a field to store an attribute distinguishing the two line types (create that field on the main rivers first and assign it a value meaning rivers and then merge the tributaries in and select the null values or 0 values for that field and calculate a value representing the tributaries).

2.  Merge the two line sets together with the merge tool as mentioned and do the necessary tributary attribute selection and attribute calculation.

3.  You may want to make sure your lines have true connectivity, and might (on a copy of your merged file) use the Integrate tool to get snapping of lines to occur. 

4. Use the Split Line at Points tool to break your lines using the barrier points (requires an Advance license).  If you do not have an advanced license, then you would need to break the lines some other way at the barriers.  I came come up with an alternative to that tool given time, but it is not an easy tool to replace.

5.  Run the Buffer tool with a small buffer to generate polygons around your lines.

6. Do Dissolve on these buffers using the single part feature option (This would not work for dissolving branching lines into one feature, but does work for merging branching polygons into one feature).

7. Now do a buffer that is only slightly larger than the one you did for your lines on the barrier points.

8. Use the Union Tool on the line buffers and point buffers.  http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000000s000000

9. Select by Attribute and delete all polygons in the Union where the FID of the point buffers is greater than -1 and delete them.

10. Use the Multi-part to Single-Part tool to make sure the buffers are separated at the boundary point locations. 

11. Use the Spatial Join tool using the One-To-Many option on the lines that were split using the Split at Points tool at step 4.

Now you should have lines that have a buffer FID that ensures those lines could all be connected together without crossing a barrier (regardless of whether they were a tributary or river).  The buffer FID represents your habitat patch ID value that associates all lines that have the same habitat patch accessibility level for your fish.  Additionally these lines still can be colored separately as rivers or tributaries based on the attribute you added at step 1.

If you want to Dissolve the lines into a single line feature (with no distinction in rivers and tributaries) use the Dissolve tool or Create Route tool on just the Buffer FID field value.  If you want rivers dissolved separately from tributaries use the Dissolve tool on the habitat patch buffer FID and the attribute you added at step 1.  Or create a text field and concatenate these two values together as a Route ID for the Create Route Feature tool.  Any of these dissolves or routes will lose any river names of the original lines and will only be useful for making it easier to select these habitat patches.
0 Kudos
wolfgangobruca
New Contributor
@Richard Fairhurst: 

That was an astonishing answer and brilliant guide support as well, many thanks for your efforts. It is definitely working and I am very surprised by this elegant solution. Saved me a lot of further time and brainracking. Respect!

:cool:
0 Kudos
RichardFairhurst
MVP Honored Contributor
@Richard Fairhurst: 

That was an astonishing answer and brilliant guide support as well, many thanks for your efforts. It is definitely working and I am very surprised by this elegant solution. Saved me a lot of further time and brainracking. Respect!

:cool:


If that gave you the answer you were looking for, there is a ghosted check mark under the arrows where you give posts points that you can check to indicate that post was the answer to your question.  Answer checks help other find solutions to problems that are similar to yours more easily.

I admit it took me a long time to get familiar with all of the tools to be able to put things like that together in my head in response to questions like yours just from hearing them and seeing an illustration like the one you provided.  But once you start wrapping your head around the flexibility and efficiency of combining a lot of smaller tools to do the work of one large workflow and get some success doing it, the lessons you learn will stick with you and ultimately allow you to come up with ever more creative solutions for your problems yourself.
0 Kudos