QGIS – How to Filter WFS Based on Values in a CSV List

csvfilterlayerspolygonqgis

I have made a map in Qgis (3.20) and added a layer of OGC WFS polygon from an online service. This layer displays coloured surfaces where buildings are, for the whole country.

I also have a list of buildings that I want to be displayed. This list is a lot shorter than the one above.

I have checked the attributes table of the WFS and the last column (BuildID) contains a number that I can match to a column in my (CSV) list. When I use the filter on the WFS layer I can indeed single out any particular building.

How do I display only those surfaces in the WFS that match the BuildID?

I have looked at joining, tried to create a new layer, looking at the query builder, etc, but I'm just not sure which path to pursue to find my answer.

Best Answer

If you're happy with a new layer dervied from the WFS then you can use join by field value tool. Personally I would perform this sort of operation using a spatial database like postgres.

First ensure your polygon layer and csv layer are loaded in the project.

Select the tool 'Join attributes by field value'

enter image description here

In the pop up, field A select your WFS polygon layer, in field B select the BuildID field.

In field C, select your CSV layer, in field D select the BuildID field.

In field E select which fields, if any, you want to join from your CSV to the output.

In field F, select whether you want one-to-one (e.g. each buildID is unique) or one-to-many (a given buildID can be shared by many buildings).

If you're only interested in the rows from your WFS that are included in the CSV then check G.

Run the above and you should have an output comprising only features from the WFS that have a BuildID included in the CSV.

Related Question