Thursday, 11 July 2019

select by attribute - Dissolving line segments in QGIS if they touch and fall within same class?


I have line segments that have the following 3 attributes (Class, start_point, end_point). I would like to merge/dissolve line segments that fall within the same class if they intersect (touch).


i.e. if the end_point of one line segment and the start_point of another line segment are the same (similar values). (NB. I would like to dissolve lines with the same class value. The dissolve field can also be a new field which will be generated when streams meet the above condition: ie they fall within the same class as well as the end_point of one segment = start_point of another segment)


Stream segments that should and others that should not be dissolved The circled numbers represent the class (order) of the streams. Each segment has a corresponding class number as shown. The segments circled in red should be dissolved separately. The same should be done for the segments circled in green. Each segment has a start_point and an end_point. For example for the segments in yellow the end_point of one segment and the start_point of the other coincide.


The lower segment circled in red should not be dissolved with the lower segment circled in green because only their end_points coincide.


How can I proceed to do this in QGIS?



Answer



@Miro, I must say thank you again. I used your approach again and found another tool that helps i.e. "split lines with lines". For every class(order) I intersect it using the next higher order. So finally the approach I used is;





  1. Dissolve (dissolve everything with the same class)




  2. Multipart to singleparts (will break lines which are not touching to single lines)




  3. Extract each class (order) of stream (therefore creating new shapefiles for each stream order)




  4. From the processing toolbox, Use the "Split lines with lines" tool - Intersect each class with a higher class.





The results are as expected.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...