5

I have polygons drawn with AutoCAD as Mline (Multiline type) which are rendered in QGIS as 8 segments for each feature. An example of one selected feature is shown in the picture below:

enter image description here

I want to clean this layer thus to only have the connected segments as polylines. An illustration of the expected result is shown below:

enter image description here

It is not possible to convert them with AutoCAD.

I used the "Multipart to Singleparts" processing to obtain 8 features instead of 1 feature composed of 8 separated segments. Here is my problem, I do not find the process to keep only the connected segments and remove the isolated ones.

Then I tried several procedures:

  • play with the "v.clean" tool from GRASS, without success.

  • use the "Shortest path" processing, which is not a solution, as I have too many features.

  • "reconstruct" polylines by generating some points along lines and connect them automatically by creating new lines lines, with the help of some plugins.

Finally, to circumvent this issue, I also tried to apply the "Buffer" processing on the 8 segments to obtain overlapping polygons. Then, the "Dissolve" processing was applied on the overlapping polygons in order to obtain one polygon describing the former lines originally drawn as multilines. Finally, the use of the "Skeleton/Medial Axis" function of the HCMGIS plugin led to a result close to the one I expected. Unfortunately, three major problems are encountered in following this procedure: loss of accuracy, unexepected small polylines generated at each curvature and a very heavy procedure (crash) for my computer (more than 3000 segments).

Does someone have an idea?

0

Your's correct line is always connected, that's mean that in every start and end point it should by exactly two points. I will suggest:

  1. Extract specific vertices 0,-1 (start and end of the line) enter image description here
  2. Make small buffor around them, and dissolve the result, after dissolve use multipart to single part to have one polygon in every start/end of the lines. enter image description here enter image description here
  3. Check number of points in polygon enter image description here
  4. Filter your count polygon where number of points are exactly two enter image description here
  5. Select lines based on that polygons selected in step 4. enter image description here

And the result: enter image description here

  • Thanks for that detailed reply. I have though two questions: 1) Why using the "Extract specific vertices " function instead of the "Extract vertices" function? When I used the first one with the given parameter, unwanted points where generated while the wanted one were not. 2) In using the "Extract vertices" function, I could pursue up to the last step. For this one, the "Select by location" function selected not only the desired lines, but also some of the other lines for some segments, without reasons. – Xavier Michael Nov 13 at 11:32
  • Can you share this part of data when is selected more than one line? Maybe you should use smaller buffer. It's depends on your data. – GSienko Nov 13 at 11:41
  • Here is the result wikiupload.com/6X5ZSNSEMJEGJ6Z I checked the size of the buffered points, that was not the problem in this case (I created very small buffered points) – Xavier Michael Nov 13 at 11:49
  • @XavierMichael The problem is very very small differences between vertices of lines. That's why you got more than one continuous line. I will suggest use v.transform and scale your layer by 1000000000. Select that one continuous line and use v.transform again but 0,000000001. Count number of decimal places – GSienko Nov 13 at 17:25
  • I followed your last instructions and it worked. Unfortunately, I couldn't used the "v.transform" function with a scale factor of 1000000000, but a 10000, as the crs's boundaries I use doesn't allow it. Thus the result led to a reduction of only 17% of the total entities number. Therefore the result is not perfect, but still better than the initial state. – Xavier Michael Nov 14 at 9:35

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.