Selecting by Location

Feb 15, 2021 | GIS

You would think after doing this for as long as I have I would “have an answer” for about everything. Last week found me going “well select by location and check…well…check….what do you want? Well pick intersects… no…within…no… cross…well……&*^%”

So I started a small journey of self discovery on “what does every check box do”. Surprisingly – I didn’t know what every checkbox did…and again – I’ve been doing this too long not to know. Yes I can read the help but…..

I pulled out all the counties that surround me and randomly generated 5000 points and buffered them. Then I just started clicking and walking through “why”. To be honest I never just create test data – and that was amazingly fast and made my life pretty simple.

So – here we go. I will select my county and crank up “Select by Location” in QGIS:

  • “Intersects” does exactly what you think it does. If the polygon “intersects” my county it is selected. I have 851 polygons touching my county.
  • “Are Within” does what I expected as I have 651 polygons within my county.
  • “Overlap” does what I want – I have 166 polygons that touch the county line. They don’t reside in any one county
  • “Disjoint” gives me everything outside. I have 4149 polygons that don’t touch my county. Which makes sense as I have 851 that intersect
  • “Contain” does nothing. Which doesn’t make sense as it says “contain”. If I select my county and and run against the 5000 polygons nothing happens. If I select a polygon within the county and flip my select: Give me all the counties that contain this one polygon – that works.
  • “Touch” does nothing because I expect it to be similar so overlap. Select my county and run against the polygons and nothing. Select my county and ask it to identify every county that touches my selected one and that works. My county touches 10 other counties.
  • “Equal” does exactly what I expect as none of my 5000 polygons “Equals” the geometry of my county.
  • The weirdest is “cross”. I had to do some digging. So with cross a polygon can cross another polygon but there is nothing but more polygons. Lets say a line crosses into the county – that intersection is a point. After doing some researching crosses mainly is for lines crossing other lines or polygons. Which if I do a little bit of trickery with QGIS by converting the polygons to lines and running “Select By Location”. We have 166 selected lines which matches what I have in overlap.

So anyway – Select by Location. It does everything you want and some stuff you’re not expecting. Which – this was fun and I might do it with another processing tool I should 100% understand and don’t.

You may also like

QGIS2Web and the Hunt for Bike Lanes

QGIS2Web and the Hunt for Bike Lanes

I was teaching a QGIS class a while back and at one point the discussion drifted into "So this OpenStreetMap thing" and I discussed how I enjoy making edits. Eventually it turned to "I'm trying to get Chattanooga's Bike Lanes into it in my spare time". One thing led...

Training Classes for January 2024

Training Classes for January 2024

So I have 3 classes coming up in Mid January that I should have been talking about sooner but....December was a bit hectic. Exploring QGIS, Model Designer, and Tips and Tricks are happening. Jump over to the Support page and you'll see the info with links. I'm pretty...

2023 – The Year End Review

2023 – The Year End Review

So if you're keeping up in 2020 I was ready to end the business thanks to Covid. 2022 was probably my best year in business in a very long time. This year was slower than anticipated BUT that's why you save money, advertise, and spend wisely. It also had it's exciting...