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.


3 Answers 3


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.


If I had this problem, I would create a table in excel with the features that I'd like to extract. After importing that table to my workspace, a join operation to this table from other table would get me all the data that I need.


ID=1440 "OR" ID=3376 "OR" ...... are you using an "OR" function between each. I don't use QGIS but I assume the functionality is the same. I think it would be quicker to sort your column "ascending" and manually select the polygons you're interested in from the attribute table.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.