3

I am trying to perform a kind of 'spatial join' in Arcgis, joining to a polygon layer atributes of the closest feature of a point layer, as well as distance. But 'spatial query' doesn't offer an option 'closest feature on target layer'.

I guess I could create a distance matrix, I've tried but the distances are something like 4695923.10207, can it be because I am working with WGS 84 non projected layers?

And, is it possible to perform the spatial join I mentioned, resulting on a layer, instead of creating a distance matrix?

0

3 Answers 3

3

Both answers from @HåvardTveite and @mapBaker should help you get your results. What I normally do is first use the Distance to nearest hub tool and then Join the resulting layer with the polygon layer.

This is a late answer but anyway, I created 2 simple layers (polygon and point) with the following attributes:

Attributes

I then ran the Distance to nearest hub via the Processing Toolbox and chose the appropriate settings:

Distance to nearest hub

This gives me a point layer as an output (I left the default name as I'm lazy) with the distances calculated:

Output attributes

Now, I Join the polygon layer with the Output layer by connecting a common attribute from each. This is done from Layer Properties > Joins:

Layer Joins

Finally, your polygon layer will contain its original attributes plus the distances calculated from the Output layer:

New attributes

If you want to keep all those attributes in a single shapefile then you can simply do a Save as... on the polygon layer or alternatively, run the Join attributes table from the Processing Toolbox.

2
  • 1
    "Distance to nearest hub" only works on points, and therefore it uses the centroid of the hub geometry to calculate the distance and create the hub line. When looking for the closest feature, one would probably want to use the distance to the nearest point on the geometry, and not the centroid of the geometry. Commented May 30, 2018 at 0:22
  • @HåvardTveite - Thanks for your comment. Yes, you are correct about the centroids being used which should probably have been mentioned. Can't remember if I knew that at the time though as it's been a few years ;)
    – Joseph
    Commented May 30, 2018 at 9:24
2

Using a projected coordinate reference system (e.g. UTM) simplifies things.

In GRASS you can use the v.distance function.

In QGIS you can use v.distance through the GRASS plugin. If your datasets are not too big you can use the QGIS NNJoin plugin.

0

Try this tutorial, or this one

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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