2

I have a lot of polygons which have a notch at the edge. I want to have the area of the notch for each polygon. In order to reach this goal I used the Convex hull tool and then clip the polygons (difference not intersection). However, it computes a bigger area then I anticipated. Since I have many polygons I do not want to delete the parts which I do not need by hand. I have two pictures to demonstrate my issue. I want the red marked area, however, there is much more area which need to be deleted. (yellow polygon is the original one and the purple one the convex hull polygon below the original polygon)

Is there any solution to only get the red marked area without doing it by hand?

enter image description here

enter image description here

The polygons actually dont look that simple. I just posted a simpler version. Here is a more realistic version of my polygons. There are round about thousand similar looking polygons. The notches here are way longer. I marked with red again which area I wanted.

enter image description here

7
  • 1
    What GIS software are you using?
    – BERA
    Oct 2, 2023 at 12:23
  • 4
    Technically: how do you define the area you want to keep/the one you want to delete? I mean from the example in the picture it seems clear, but how to deal in other cases (e.g. this case: i.stack.imgur.com/hwxSW.jpg)? What is the criteria that defines which part belongs to the "notch" and whicht part(s) not? As a first recommandation: try concave hull.
    – Babel
    Oct 2, 2023 at 12:36
  • I use R and QGIS. I want the area which is marked in red. I define it by connecting the inner corners not the one competely outside. If that makes sense. I did try concav hull but it didnt give me a satisfying result.
    – Lina
    Oct 2, 2023 at 14:06
  • 2
    This still doesn't answer the question how the part you want to delete can be distinguished from the part you want to keep. Without a clear definition, it is difficult to answer. Maybe based on some criteria based on angles, number of vertices...
    – Babel
    Oct 2, 2023 at 18:54
  • In this and subsequent questions, be sure to post a download link for your example geodata, so that potential responders don't have any geo-fantasies and misunderstandings.... Oct 4, 2023 at 17:14

2 Answers 2

1

I have a layer with complex geometry:

enter image description here

I need to remove all the inner vertices to have as a result the following polygons:

enter image description here

To achieve that:

  1. I extract the vertices using the "Extract Vertices" algorithm:

enter image description here

enter image description here

  1. Using the "Delaunay Triangulation" algorithm I will create polygons

enter image description here

See results below:

enter image description here

  1. I will create "Concave Hull" using the "Concave Hull (K-Nearest Neighbor)"

enter image description here

(Note: in my case I chose 4 instead of 3 for the "Number of Neighboring Points ...." to have smoother results. You may have to try other values.)

Here is the result:

enter image description here

  1. I extract by Location using the "Extract by Location Algorithm" using the following settings:

enter image description here

The result looks like this:

enter image description here

  1. I will merge the extracted data with the original polygons:

enter image description here

Check your settings:

enter image description here

Here are my polygons:

enter image description here

  1. But we need to remove the lines, to achieve that we use the "Dissolve" algorithm:

enter image description here

enter image description here

Done !

enter image description here

The issue now is that the result has created multipart polygons.

  1. We need to create multi parts polygons using the "Multipart to Singleparts"

enter image description here

enter image description here

Here is the final result:

enter image description here

enter image description here

  1. You will have to extract the attributes from the original layer and put them into the newly created layer. You need to use the "Overlap Analysis" algorithm:

enter image description here

enter image description here

enter image description here

  1. (Optional) in case if in step #4 you would like to remove the flat polygons (see picture below - yellow color polygon):

enter image description here

Use the "Roundness" algorithm:

enter image description here

If you open the attribute table of the new layer, you would notice that there is a field called "Roundness" and remove any polygons that have the value below 0.1 (this value is subjective to the person and the purpose of the analysis). The closest is the number to 0 (zero) the flatter is the polygon.

enter image description here

enter image description here

Continue the same steps with the "Roundness" layer and the final results will be as below:

enter image description here

6
  • Thanks a lot for your help. However, I have one question. For some reason it didnt work for the pink right hand polygone. There is one point on the far right edge where it didnt work. It creats exactly the problem I describe. For some reason it worked for the rest of the points. Do you have any explanation for that?
    – Lina
    Oct 4, 2023 at 11:52
  • I would of you could share that specific polygon. You can move it somewhere else on earth if it is confidential data.
    – GforGIS
    Oct 4, 2023 at 11:57
  • Its your example which has this little error. In the right pink polygon. Right site of the polygon the second point from the bottom. its is not in the line its a bit outside of the line. Its inside the polygon just a tiny bit. With all the other points it alignes with the line correctly. I only talk about your example cause I am wondering why it didnt work there for some reason. Do you have any idea?
    – Lina
    Oct 4, 2023 at 12:16
  • Most probably it is the value in the concave hull that needs to be higher than 3 which is the default value. Perhaps a 4 would do. Depending on the precision you need that might be enough in some cases. In my case if it was only one point I would just edit it manually, but that is me.
    – GforGIS
    Oct 4, 2023 at 13:32
  • I just tried it out and the results after the "Extract by Location Algorithm" is not satisfying at all. It covers the areas only a bit but not enough.
    – Lina
    Oct 4, 2023 at 15:43
1

Introduction.

  1. The convex hull tool has no problem.
  2. The requirements for solving your problem are of a particular nature and have to do with the complex polygons shown in your figure.
  3. The method is called: "Constructing an additional interior notch of a polygon by using interior vertices".

Addendum 1: The method works for your first pair of drawings. You then published your second pair of drawings. For the left drawing the method will also work, but for the second one you will have problems with the burrows, as you will additionally have to tighten the holes in the burrows.

Main part.

Here are simple steps that solve your problem with the help of geo-tools built into the special QGIS software. For the original geodata, see your and my Figure 1.

enter image description here

Figure 1.

Step 1 - Extract the vertices of complex polygons. (Vector->Process geometry->Extract vertices...) see figure 2.

enter image description here

Figure 2.

Step 2 - Perform Delaunay Triangulation (Vector->Geometry Processing->Delaunay Triangulation...) see Figure 3.

enter image description here

Figure 3.

Step 3 - Find the difference between the "Delaunay Triangulation" and the "Original Geodata" (for me "grid_test") see Figure 4.

enter image description here

Figure 4.

Step 4 - On the source geodata, create a virtual layer with the following expression

SELECT st_buffer(st_union(st_buffer((geometry),-0.0001)),0.0001) geometry from grid_test see Figure 5.

enter image description here Figure 5.

Addendum 2: The smoothed shapes of the original polygons obtained by double-bufferization with semicircular shapes will allow you to select the outer or inner vertices in the next step!!! see Figures 5.1 and 5.2 respectively.

enter image description here

Figures 5.1

enter image description here

Step 5 - Perform intersection (selection) of the inner vertex of each complex polygon from the vertex layer and "virtual layer", use "Vector->Geoprocessing->Intersection..." see Figure 6.1 и 6.2.

enter image description here

Figure 6.1

enter image description here

Figure 6.2

Step 6 - Buffer the selected interior vertices a bit to reliably select the required truegons.

Step 7 - Extract by spatial relation (check the checkbox - intersects) to the "Difference" layer (step 3) and the "Bufferized" layer see Figure 7.

enter image description here

Figure 7.

Step 8 - Combine the result of step 7 "Vector-Geoprocessing-Combine by Feature" see Figure 8.

enter image description here

Figure 8

Conclusion.

Calculate the required area of your excavations on your own.

The answer to your question has been kindly provided for you by the founder of FOGS.

3
  • Thank you very much for help. Thats basically what I want. However, I dont understand your steps 4-8. Why did you create this buffer within a virtual layer. How did you get the inner vertex of each complex polygon? (Step 5).. From step 1-4 you gave every tool etc. I liked that cause then I can follow your steps better. I also have more complex polygons which have not that simple shaped notches. I cannot put another screenshot in this comment section so Ill post a proper answer to my question. Could you have a look there as well?
    – Lina
    Oct 4, 2023 at 8:10
  • Step 4 is the most important for your case, because double buffering on the original geodata will get rid of the outer vertices and leave the required inner vertices in the next step! Step 5 use "Vector->Geoprocessing->Intersection..." to get only the interior vertices from your original very complex polygons... Oct 4, 2023 at 17:45
  • I tried to figure out what you did in step 4 but really dont understand what you did there. The same with step 5. It seems to me that you buffer negativaly and then union it (I dont know why you did that either) and then buffer back to the original shape... why do you do that? Also I have way more complex polygons which you can see in my edited post. Is it also working for this kind of shapes?
    – Lina
    Oct 12, 2023 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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