Provided the following
Polygons layer with 6 polygons (see image below), I would like to calculate each line's segment's angle (amongst other things), so I should convert those six polygons into lines, where each line should have only two vertices (start and end).
As far as I know (I am far from being an expert), I could do the following:
- Convert polygons into lines with
Polygons to linesalgorithm, which results into 6 closed lines with the same attributes as the polygons in
- Split the lines into segments with GRASS'
2as the maximum number of vertices in segments (see screenshot with the configuration I used) [EDIT: after Spacedman comment, I have discovered that I could also use
Explode linesalgorithm] 4
That would work if it weren't that I happen to have a vertex with id
38 (see first screenshot) which is redundant, as it breaks one line that does not have any other intersections nor angle's changes into two segments.
Is there any way to deal with such redundant vertices? (Of course, the image is just a sample of a much more complex layer with many more vertices like that and I cannot manually fix them).
I know I could use
Simlify algorithm, but unfortunately, it would not solve my problems because currently only offers three ways of simplifiying:
- Distance-based: I cannot use this method, as the offending vertex is in the middle of the segment and far beyond any reasonable threshold. If I used that distance as threshold I would dramatically change the geometry with much worse negative effects.
- Snap to grid: I do not have any grid to snap vertices to
- Area: I cannot use it, as I am working with lines.
Surprisingly there's no method to fix vertices within a line where its neighbouring segments have the same azimuth angle, which would solve my problem.
From what I read,
v.clean provides a tool called
bpol which may be what I am looking for. From its manual:
bpol: break (topologically clean) polygons (imported from non topological format, like ShapeFile). Boundaries are broken on each point shared between 2 and more polygons where angles of segments are different
Unfortunately, I haven't succeeded in using it, and when I want to run the tool using
Lines layer as input layer, I get unexpected results, as only 10 vertices are used as "slicing" vertices which result in 24 lines, many of them have several segments with different angles (see image below):
At this point I have two questions:
- Is there any other way to achieve what I want to achieve?
- Am I doing something wrong with
v.clean(which, I have to admit that I have failed miserably on all my attempts to use
v.cleaninside QGIS 3.2 in Linux for other purposes)?