I have a project in QGIS with two layers, one with several geographical zones (imported from a Shapefile file), and one with several points (imported from a CSV with longitude/latitude coordinates).

I would like to map each point to the ID of the zone that contains that point, i.e., create a new CSV in the form "longitude,latitude,ID". How can I do it in QGIS (or, possibly, any other "scripted" solution)?

2 Answers 2


You need to do the following:

  1. After loading the CSV file, right-click the file in the table of content -> Save as -> Choose shapefile format and make sure you select the CRS that matches the polygon shapefile CSR
  2. Use Join attribute by location that you can find it from Vector -> Data Management Tools -> Join attribute by location
  3. Save the output file as a new shapefile
  4. Then you can save the shapefile again as CSV by right-click the file shapefile in the table of content -> Save as -> Choose CSV file. In the layer Option -> Geometry -> choose 'Default' if you want to keep the original coordinate without appending another XY field to CSV output file, as you can see below:

enter image description here


What you are looking for is called a "spatial join". In QGIS you can find such functionality under Vector -> Data Management Tools -> Join attributes by location or directly in the Processing Toolbox.

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.