Adding attributes to datapoints from overlapping polygons in qgis

ALs picture ALs · Sep 4, 2015 · Viewed 8.6k times · Source

I have an interesting problem in QGIS, I have a vector layer of points (shown in purple) and a layer of polygons (green) with a number of metadata attributes attached (i.e. date, id number etc).

I want to attach the data from the polygon to the point data underneath them. The problem is I have some overlap where point data is covered by two polygons.

In these instances I essentially want to duplicate the point data so in the attributes table for the layer I have a point for each polygon which overlaps, with corresponding meta-data. This means I can't simply use the "Join attributes by location" tool as it will only assign data from the closest polygon, or a sum/mean etc of the two overlaps.

An illustration of the data is below. Any suggestions on how to solve this problem would be most appreciated.

enter image description here

Answer

ALs picture ALs · Sep 4, 2015

After a bit of faffing I've found a solution that works quite well.

  • Firstly open the "Clip points with polygons" tool in the "processing" plugin.
  • In the menu select your points layer and your polygon layer.
  • Select the green circle arrow in your polygon layer to set it to iterate over each polygon.
  • Select the attribute you want to add to the points layer.
  • Select "seperate layer for each polygon".
  • Name the output folder (best to create an individual new folder to help with merging later) and hit OK.
  • Next go to Vector->Data management tools->Merge Shapefiles to One
  • Select shapefile type "point"
  • Select input directory as the directory where you created all your earlier points files
  • Hit run

You should now end up with a layer containing points with data from more than one polygon where they overlap. The only problem I have is you can only add one piece of data from the polygon with the clip tool, this is fine for me at the moment but could be an issue.

If anybody knows of a different/better way or a way of adding more than one bit of data from the polygon please add it.