[GIS] Searching for several different features in attribute table using QGIS

qgisquery

I am using the query builder.

I have a long attribute table in QGIS and am trying to extract about 200 fields with a certain ID, e.g. ID 4440 and 3376 and 3156 and so on.

It's too much to do it manually and I'm pretty sure that there is a neat command, but somehow everything I tried is not working.

The original data set is a shapefile of rectangles – I have used this to calculate points in polygons, which I have copied to excel to combine several datasets and calculate total numbers of points per polygon. Now I have the IDs of each polygon and the number of points in an excel sheet and sorted this by the number of points, which gives me a random order for the polygon IDs, e.g. ID 4440 with 9 points, ID 3376 with 7 points, etc. – I can't load and map the excel file because there is no coordinate data, I just want to pick the cells containing >1 point from the original rectangle shapefile.

Best Answer

I am not familiar with QGIS either but assuming the functionality is the same or at least similar to that of ESRI you could try the definition query:

"ID" In (4440, 72639, 92736, etc)

But if you have over 200 entries and you don't wish to type all 200 out this way I would suggest utilizing the above mentioned technique with the Excel spreadsheet.

Again, I don't know QGIS so this may not work but give it a try. Take your Excel spreadsheet and save it as a .csv (Comma Delimited) file - ESRI says it works with Excel directly but I find it still works best if not in an .xlsx file format so QGIS may be similar. You should then be able to load the table into your map document as just a data table and therefore the coordinates should not be required. Then you can do a table join, joining your .csv to the rectangle shapefile based on the 'ID' field. There should be an option to select what values are returned, more specifically an option that will only return matching values. So as long as the ID matches in both tables those are the only records returned everything else will be temporarily removed until you remove the join. While the join is active you should then be able to select all records and create a new shape with only the records with the ID's that you want.