1

I have a layer with several polygons and want to extract the "mid/center-point" of the touching borders/lines of adjacent polygons. Despite trying several methods, I do not know how to achieve what I had wanted.

What I tried recently:

  1. I used Polygons to lines to convert the polygons to lines
  2. I then used Explode lines to split the lines at vertices

But Explode lines just splits at all of its vertices. I am thinking that the steps might be to:

  1. Convert the polygons to lines
  2. Split the lines at vertices only if there is one or more line touching the vertex (like splitting the lines only where the black dots are as shown in the screenshot below):

Split at vertices

  1. Find the mid-point (point coordinates) of each of the resulting split lines (which would be the red dots below):

Mid-points of split lines

What are the steps and algorithms needed to achieve this (extract/get the red dots as shown in the image)?

Update: I tried QChainage plugin but not all common vertices were extracted (like these green circles):

QChainage test

  • There's a "split lines" algorithm, have you tried that? – ndawson Aug 25 '18 at 1:39
  • In ArcGis there is a dissolve lines, no multiparts option. Most likely similar thing exists in qgis. No need to split at vertices after step 1. – FelixIP Aug 25 '18 at 3:19
1
  1. Download the QChainage From the plugin repository
  2. Open the plugin under Vector > QChainage
  3. Select the layer under the "Basic" tab
  4. Under the "Advanced" tab, put "2" into "Divide Features into _ Parts" and execute
  5. Start an edit session on the resultant layer
  6. Use Vector > Research Tools > Select by location to select the points in the resultant layer which intersect the start and endpoints of the original lines
  7. Delete these features
  8. Save edits

EDIT:

It seems that your lines are not topologically correct, in that some of your lines are touching other lines' endpoints without being split into a new line. To fix this, use Processing Toolbox > GRASS GIS > v.clean and select the "break" option for the "tool" parameter. That should break all of your lines into individual segments.

  • Thanks. I tried the steps but not all common vertices in the original line layer were extracted. Please see new screenshot above. – JAT86 Aug 25 '18 at 19:59
  • 1
    @JAT86 I updated by answer with a tool you can use to break the lines at intersections. – wfgeo Aug 27 '18 at 9:56
  • QChainage though does not preserve the feature attributes. Is there an alternative way/method to also include the attributes for the created midpoints? – JAT86 Aug 31 '18 at 2:04
  • I would suggest doing a spatial join of the source line features to the points. – wfgeo Aug 31 '18 at 13:01
  • I do not know if it is my source file that is the problem, but even though I used GRASS v.clean (break) on the original line layer, several midpoints resulting from QChainage do not get the attributes from the lines after doing a "Join attributes by location". (By the way, the line layer itself was converted from a multipolygon layer using the MMQGIS plugin's "Convert" function. I am just not sure if the conversion had an effect on the topology of the original borders..) – JAT86 Aug 31 '18 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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