[GIS] QGIS NNJoin – Add Point to Single Nearest Polygon

distanceqgis

I know there have been tons of posts on this, but none of them seem to answer my question/situation. I have a layer of many polygons (building footprints) and I'm trying to join a of points (less points than polygons). I am trying to join the attributes from each point to the closest polygon. When I use NNJoin, I get a resulting layer where each polygon has assumed the attributes of the closest point to it. Similar posts are here and here. In many instances, my points are not within a defined polygon. Maybe I'm missing some settings in NNJoin?

NNJoin interface here; 'Building Outlines' is my polygon layer and 'Building Properties' is my point layer. Do I have the settings correct?

enter image description here

Am I right in understanding that if I check 'Approximate geometries by centroid' it will find distance based on centroid, but if I leave it unchecked it will base it on closest line of the polygon?

Best Answer

You write: I am trying to join the attributes from each point to the closest polygon. So you seem to be looking for the closest polygon to each point. The only way to achieve that with NNJoin is to use the point layer as input layer and the polygon layer as join layer. The result will be a new point layer that for each point in the input layer contains the attributes of that points, the attributes of the nearest polygon and the distance from the point to that polygon (from the point to the closest point on the polygon).

You say you want to add attributes from each point to the closest polygon. The problem is that there can be many points that have a certain polygon as its closest polygon.

If you use the polygon layer as input layer and the point layer as join layer, your result will be a new polygon layer that for each polygon in the input layer contains the attributes of that polygon, the attributes of the nearest point and the distance from the polygon to that point (from the closest point on the polygon).

Regarding 'Approximate geometries by centroid', the Plugin help (that you can find by pressing the Help button) says:

The user can choose to use an approximation of the input geometry (the centroid - QgsGeometry.centroid) to allow the use of spatial indexes also for non-point input layers.