havatv / qgisnnjoinplugin

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

NNJoin returning all "-1" or "0" values #19

Closed jaymschoen closed 5 years ago

jaymschoen commented 5 years ago

I've been using NNJoin 3.1.1 in QGIS 2 and 3 to calculate distances from species presence/absence points (point or multipoint) to environmental features (point, line, multiline, polygon). It worked great for some time but now just returns all "-1" or "0" values for my entire vector. Even when I run it with the same input and join layers that worked in the past, I get this result. The issue only seems to occur when joining to multiline string objects and when I inspect the resulting layer, it looks like only one feature was selected to join (with a uniform distance of "-1" or "0").

Thanks in advance for your help!

jaymschoen commented 5 years ago

I was able to get it working by converting any multipoint files to singlepoint, but I am still unsure what caused the issue as multipoint files had worked fine before. I also created a spatial index for my point shapefile, but am not sure if that made a difference. Thanks again for the plugin.

havatv commented 5 years ago

Thank you for reporting, @jaymschoen! The distance calculations in NNJoin rely on the QgsGeometry distance function (which uses the GEOS distance function) and the QgsSpatialIndex functions. The index is built by the plugin. I don't think presence or absence of a spatial index on the datasets should matter. Could you share small sample datasets that demonstrate the issue?

jaymschoen commented 5 years ago

Thanks for getting back! I’ve attached the main files I was trying to use the plugin for (a subset of generated pseudoabsences, PA 272 group 1, and a shapefile of the main roads in Paraguay, pyrutas_nuevo). I realize that there are several geometric errors in the main roads shapefile, but I still don’t understand why it worked before then stopped, and now seems to be working fine. The plugin is working great on singlepoint files that I am analyzing today…

Please let me know if I can provide anything else.

Cheers, Jay

From: Håvard Tveite Sent: Monday, February 25, 2019 7:29 PM To: havatv/qgisnnjoinplugin Cc: jaymschoen; Mention Subject: Re: [havatv/qgisnnjoinplugin] NNJoin returning all "-1" or "0" values(#19)

Thank you for reporting, @jaymschoen! The distance calculations in NNJoin rely on the QgsGeometry distance function (which uses the GEOS distance function) and the QgsSpatialIndex functions. The index is built by the plugin. I don't think presence or absence of a spatial index on the datasets should matter. Could you share small sample datasets that demonstrate the issue? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

havatv commented 5 years ago

@jaymschoen, in order to attach the files, you first need to zip them into a .zip archive and then drag and drop the .zip file into the box.

jaymschoen commented 5 years ago

Sorry about that.

Jay

From: Håvard Tveite Sent: Tuesday, February 26, 2019 3:01 PM To: havatv/qgisnnjoinplugin Cc: jaymschoen; Mention Subject: Re: [havatv/qgisnnjoinplugin] NNJoin returning all "-1" or "0" values(#19)

@jaymschoen, in order to attach the files, you first need to zip them into a .zip archive and then drag and drop the .zip file into the box. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

havatv commented 5 years ago

Follow the link ("view it on github") at the bottom of the email to get to the github page where you can drag and drop the .zip file to add it to github.

jaymschoen commented 5 years ago

I don’t have permission to share the main roads file publicly so I sent it here instead; is it possible for you to open it via email to analyze?

Thanks, Jay

From: Håvard Tveite Sent: Wednesday, February 27, 2019 2:12 AM To: havatv/qgisnnjoinplugin Cc: jaymschoen; Mention Subject: Re: [havatv/qgisnnjoinplugin] NNJoin returning all "-1" or "0" values(#19)

Follow the link ("view it on github") at the bottom of the email to get to the github page where you can drag and drop the .zip file to add it to github. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

havatv commented 5 years ago

Thanks for sending me the sample data, @jaymschoen. I could reproduce the behaviour you reported. The only way I could make it work with the current NNJoin version was to change both layers to singlepart ("Multipart to singleparts") before running NNJoin. I will have to look into this.

havatv commented 5 years ago

It turns out that the NNJoin code does not handle features with missing geometries. Should be possible to fix.

havatv commented 5 years ago

Should be fixed now. Version 3.1.2 includes the fix and has been uploaded (and is available) on plugins.qgis.org. Thank you for reporting, @jaymschoen ! Much appreciated. You can now test with the new version.

jaymschoen commented 5 years ago

My pleasure, thank you for your responsiveness and quick fix! Take care