[GIS] Map point with coordinates to zones in QGIS

coordinatesqgisshapefile

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)?

Best Answer

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

Related Question