I realize from Splitting shapefile into separate files for each feature using QGIS or SAGA that I can split a shapefile by attribute, but I'd prefer to be able to just exclude certain data when I'm running various analyses on that data.

For example, I have a column "COLORS" in the attribute table, and I want to exclude only the cell value 'RED' within that column.

How do I do this?

  • Probably through a Filter..., i.e. "COLOUR" = 'RED'
    – Taras
    Nov 8 '18 at 18:08
  • Yeah, I was able to filter it, but I just wasn't clear on how to exclude it from the dataset vs. just sorting the data within the attribute table.
    – BogBody
    Nov 8 '18 at 18:10
  • After you filtered I can suggest to create a virtual layer or alternatively save it as a new shapefile.
    – Taras
    Nov 8 '18 at 18:14

Filtering a layer should exclude the filtered data from any analyses - that's an advantage of a filter vs just visually excluding those features with rule-based symbology. Sometimes there are bugs where filtered data is actually included, so it's safest to create a separate shapefile. There are multiple ways to do this, here are two:

  1. The Split Vector Layer tool

    "This algorithm takes a vector layer and an attribute and generates a set of vector layers in an output folder. Each of the layers created in that folder contains all features from the input layer with the same value for the specified attribute. The number of files generated is equal to the number of different values found for the specified attribute." - QGIS Split Vector Layer tool description

  2. Select the features you want to extract. Right click on the layer name (in the layer panel) > Export > Save Selected Features as...

    • Use the Select Features by Value, Select Features by Expression, and Invert Select tools to select exactly the features you want

Build a query on your dataset: https://docs.qgis.org/2.8/en/docs/user_manual/working_with_vector/query_builder.html

In your example above, it would be: "COLORS" != "RED'

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.