havatv / qgisnnjoinplugin

GNU General Public License v2.0
7 stars 8 forks source link

Finding second, third, ... nearest neighbor #16

Closed josempascual closed 5 years ago

josempascual commented 6 years ago

Hi,

I’m trying to find the distance between cities (point) and the closest states (MultiPolygon). The problem is that obviously the closest state polygon to each city is the state where the city is.

Is it possible to add the option of finding the second, third, etc. nearest neighbors?

By the way great plugin!

Thanks, José Miguel

havatv commented 6 years ago

Thank you for the input, @josempascual. I will have a look at it when I get some spare time...

havatv commented 6 years ago

An option has been added that, if checked, will use the closest non-containing polygon (for a point input layer and a polygon join layer). The option is not available for multi-polygon layers.

deleteselected commented 5 years ago

Hi, I was wondering if you have added to your tool a way to get 2 closest points, I have a situation where I would like the distance to fence lines for a building polygon.

havatv commented 5 years ago

The QGIS algorithm "Join attributes by nearest" should be a good replacement for NNJoin. It is available in QGIS 3.8, and supports "K-nearest neighbour joins". Could you check if it solves your "problem"?

deleteselected commented 5 years ago

I have tried it but I think there is a problem with the x coordinate calculation since I would like to generate lines to indicate where the distance was taken. running "Join attributes by nearest" gives the following columns feature_x, Feature_y, nearest_x and nearest_y see the image below for a sample of my feature_x coordinate that is messed up. image

deleteselected commented 5 years ago

I ran "Join attributes by nearest" again today and the fields are turning out proper I think my feature_x before was the distance field a column was dropped from the end.

Thanks for your help!