TransWikia.com

Can I filter a subset of the polygons without affecting the rest of the polygons in QGIS?

Geographic Information Systems Asked by Patrick S. on May 19, 2021

When using QGIS 3.10, I often filter out unneeded features to create my maps. Is there a way for me to filter a subset of the polygons without affecting the rest?

For example:
The shapefile I have contains states and counties as of 1860. All of the polygons have a STATE attribute and a COUNTY_TYPE attribute. For South Carolina, I need to show polygons with "COUNTY_TYPE" = 'District,’ but all other states need to show polygons with "COUNTY_TYPE" = 'County' (based on my data). I tried using an if/then operation in Query Builder, but this showed me only SC and eliminated the other states.

Can I filter the map to affect only SC while keeping the other states the same?

2 Answers

In the query builder, select first the condition for South Carolina, then for anything not South Carolina

(STATE= 'South Carolina' AND "COUNTY_TYPE" = 'District') 
OR (STATE != 'South Carolina' AND "COUNTY_TYPE" = 'County')

Correct answer by JGH on May 19, 2021

Concat (use pipes: ||) "STATE" and "county" for filter conditions:

"STATE" || "county" = 'South CarolinaDistrict' 
or ("STATE" || "county" LIKE '_County' AND "STATE" <> 'South Carolina')

Answered by Babel on May 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP