1

I am using QGIS (2.4.0) and I am trying to identify regions in Australia that are close to working mines. For this purpose I have 2 layers:

  • Layer 1 - 535 polygons defining the various regions across Australia
  • Layer 2 - Points indicating the location of operating mines

I have used "select by location" to identify the polygons in layer 1 that contain a mine.

However my problem is that there are some small polygons in layer 1 (based around towns) that don't actually contain a mine but are within a large polygon that does. I would like to find a way to select these polygons automatically.

Ultimately I am looking for a function that does something like: "Select polygons in Layer 1 entirely contained within currently selected polygons (in layer 1)".

The image below shows one example of what I want to do. The large polygon is already selected using select by location because it contains a mine. I then want to be able to automatically select the smaller polygon contained within it (and do this across the whole layer).

enter image description here

  • There should be an option in the Select by Location dialog to use Selected geometries. After running the first select, you'd check that box and run a new select with that layer as both source and reference (assuming it will let you) and the correct method. Not sure what methods are available, but 'within' might work depending on how it's implemented. – Chris W Dec 3 '14 at 0:19
  • Thanks for the reply. This almost works but unfortunately the select by location dialogue only contains the option to select intersecting features not those within currently selected polygons. Is there another select option that might let me do a within polygon select? – KTP Dec 3 '14 at 0:32
  • The selected features bit would be a check box under source and reference (see image at step 23 here). The method ("Where the feature") is separate, and probably defaults to Intersects but should be changeable. But you might be looking at a different dialog box than I am. – Chris W Dec 3 '14 at 0:39
  • Yes I was using "select by location" instead of "spatial query". This nearly works, but unfortunately spatial query won't let me reference the same layer twice. I will play around with spatial query and see if there is some way I can get it to work, maybe by duplicating the layers. – KTP Dec 3 '14 at 0:49
  • I ended up duplicating the layer, removing large areas and then doing "touches" in the spatial query window. This approximated what I wanted well enough with a bit of manual editing. "Contains" or "within" seemed to only select polygons tat were actually inside another one, not surrounded by one. – KTP Dec 3 '14 at 2:17
2

I suspect this is not the easiest way to do this, but it worked for me. Thanks to Chris W for pointing me in the right direction.

Steps I used to select small donut polygons within larger selected polygons:

STEP 1. Calculate area of polygons in layer 1 (using field calculator and $area).

STEP 2. Create duplicate of layer 1 (right click layer and select duplicate).

STEP 3. In duplicate layer delete all polygons larger than 2500km2. (This was sufficient for my purposes as all the areas I needed to select were small town based polygons).

STEP 4. Select the polygons in layer 1 that contain a mine using "select by location" in vector menu > research tools >select by location).

STEP 5. Use the spatial query plugin (in vector menu) to select all polygons in the duplicate layer that "touch" (select touches from the "where the feature" drop down menu) selected polygons in layer 1 (make sure box for selected geometries is checked for the second layer).

NOTE: If there are small polygons that are touching a large one, but are not entirely contained these will also be selected.

  • 1
    As noted above, the reason within and contain don't work is because you have donut polygons - there are actually holes in the surrounding shapes rather than just overlapping. However another approach to the issue takes advantage of this - donuts are automatically multi-part features (inner and outer rings). If you Multiparts to Singleparts the layer, you eliminate the holes and are left with overlapping polygons, in which case they would be within/contained. You'd probably end up with two of the smaller shape on top of each other though. – Chris W Dec 3 '14 at 19:48

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.