简体   繁体   English

将属性添加到 qgis 中重叠多边形的数据点

[英]Adding attributes to datapoints from overlapping polygons in qgis

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 (ie date, id number etc).我在 QGIS 中有一个有趣的问题,我有一个点向量层(以紫色显示)和一个多边形层(绿色),其中附加了许多元数据属性(即日期、ID 号等)。

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.任何有关如何解决此问题的建议将不胜感激。

在此处输入图片说明

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接下来去 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.如果有人知道不同/更好的方法或从多边形添加多于一位数据的方法,请添加它。

I believe this can also be done using the intersect geoprocessing tool (Vector- Geoprocessing Tools - intersect).我相信这也可以使用相交地理处理工具(矢量-地理处理工具-相交)来完成。 At least for me it works when I have a point layer with points in overlapping buffers of a polygon layer.至少对我来说,当我有一个点图层在多边形图层的重叠缓冲区中时,它是有效的。 When I intersect I then have one, two or more records per point in the attribute table, depending on how many polygons overlap.当我相交时,属性表中的每个点都有一个、两个或多个记录,具体取决于多边形重叠的数量。

This way you also get all the attributes from the other layer.通过这种方式,您还可以从其他层获得所有属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM