1

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?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
BogBody
  • 373
  • 4
  • 11
  • Probably through a Filter..., i.e. "COLOUR" = 'RED' – Taras Nov 08 '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 08 '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 08 '18 at 18:14

2 Answers2

4

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
csk
  • 24,827
  • 3
  • 32
  • 70
2

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'

cl3
  • 1,936
  • 1
  • 13
  • 26