I have a shp file that is missing some data, e.g. attributes. I have the missing data in a csv file. How can I get ONLY the relevant rows from the csv file added to the current shp file's data table? I.e. ONLY those who match the rows that are already in the shp file.

The good news is yes, they both have the same ID code in a column of each, so 'lining them up' should be easily do-able.

I am using QGIS.


You can simply use join.

Import your CSV into qgis and mark 'no geometry' to get a non-spatial data table. Open your shape files properties and choose the 'joins' tab. Add a new join with the '+' sign on the bottom-left, and define the Primary and foriegn Key fields.

You can also define which fields to join. That is it. In case of mismatch, rows won't be joined into your shapefile. See result in the image below. You can see that my csv table as more rows, with different IDs that my shapefile is missing. You can also see that those weren't include in tht output of the join.

To make the join permanent save the result to a new shape file.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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