havatv / qgisnnjoinplugin Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v2.0
License: GNU General Public License v2.0
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
In some cases, the plugin icon does not show up in the toolbar and menu in QGIS.
Installing this plugin from the zip file produces the following:
Couldn't load plugin 'qgisnnjoinplugin-master' due to an error when calling its classFactory() method
ModuleNotFoundError: No module named 'qgisnnjoinplugin-master.resources'
Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 423, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/Users/jikaczmarski/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgisnnjoinplugin-master/__init__.py", line 38, in classFactory
from .NNJoin_plugin import NNJoin
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/Users/jikaczmarski/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgisnnjoinplugin-master/NNJoin_plugin.py", line 43, in
from .resources import *
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'qgisnnjoinplugin-master.resources'
Python version: 3.9.5 (default, Sep 10 2021, 16:18:19) [Clang 12.0.5 (clang-1205.0.22.11)]
QGIS version: 3.34.1-Prizren Prizren, 133927424d9
Python Path:
/Applications/QGIS.app/Contents/MacOS/../Resources/python
/Users/jikaczmarski/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/jikaczmarski/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/rasterio-1.1.5-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/pyproj-3.2.0-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/Fiona-1.8.13.post1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9
/Applications/QGIS.app/Contents/MacOS/lib/python39.zip
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/scipy-1.5.1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/opencv_contrib_python-4.3.0.36-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/lib-dynload
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/statsmodels-0.11.1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/pandas-1.3.3-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/matplotlib-3.3.0-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/geopandas-0.8.1-py3.9.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/numba-0.50.1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/netCDF4-1.5.4-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/cftime-1.2.1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/patsy-0.5.1-py3.9.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/Pillow-7.2.0-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/Rtree-0.9.7-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/GDAL-3.3.2-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/numpy-1.20.1-py3.9-macosx-10.13.0-x86_64.egg
/Users/jikaczmarski/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/jikaczmarski/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/mmqgis/forms
Many geometry types are currently not reported correctly in the user interface, and an error is reported - for example:
CRITICAL Error: Unknown or invalid geometry type: 1002
File "/home/alexander/.local/share/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/NNJoin_plugin.py", line 137, in run
self.dlg.progressBar.setValue(int(0.0))
TypeError: setValue(self, int): argument 1 has unexpected type 'float'
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!
If the CRS of the join layer differs from the CRS of the input layer, a CRS transformation error is reported. Probably an effect of API changes in QGIS 3.0.
There were no issues with threading in QGIS 2, but apparently there is a problem with this plugin in QGIS 3.
Here is the message (on Ubuntu 16.04, QGIS 2.99.0-Master - 287ed2d; QT 5.5.1, Python 3.5.2) that appears in the log message panel QT tab:
QObject::setParent: Cannot set parent, new parent is in a different thread
The QT message appears when the processing is done and the data set appears in the legend.
hi
on Qgis 3.22 after install NNjoin
`2022-07-23T17:30:35 CRITICAL Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 423, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/laurent/.local/share/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/init.py", line 38, in classFactory
from .NNJoin_plugin import NNJoin
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/laurent/.local/share/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/NNJoin_plugin.py", line 65
^
SyntaxError: invalid character '·' (U+00B7)
2022-07-23T17:35:15 CRITICAL Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 423, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/laurent/.local/share/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/init.py", line 38, in classFactory
from .NNJoin_plugin import NNJoin
File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/laurent/.local/share/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/NNJoin_plugin.py", line 65
^
SyntaxError: invalid character '·' (U+00B7)
2022-07-23T17:39:03 WARNING Traceback (most recent call last):
File "/home/laurent/.local/share/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/NNJoin_plugin.py", line 137, in run
self.dlg.progressBar.setValue(0.0)
TypeError: setValue(self, int): argument 1 has unexpected type 'float'`
QMessageBox
should be imported in NNJoin_gui.py
from qgis.PyQt.QtWidgets import QMessageBox
The question about that issue: https://gis.stackexchange.com/q/381210/29431
In QGIS 3, the cancel button is active, but the program is not aborted when the button is pressed.
It can be useful to limit the join to selected features only.
Many thanks for your plugin. Could you maybe adapt it to use the new API of qgis3? More exactly, pendingFields() does not exist any more and should be replaced by fields().
https://github.com/qgis/QGIS/blob/master/doc/api_break.dox
Thanks in advance!
@raymondnijssen Thanks for maintaining this very nice plugin so far. In case you still do:
I downloaded the zip-file from your place.
The plugin works like a charm in QGIS ver. 3.22, but not in ver. 3.32.2.
It gives med this:
Python Stack Trace
Windows fatal exception: access violation
Current thread 0x00007844 (most recent call first):
File "C:\Users/abni/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgisnnjoinplugin-progressbar\NNJoin_plugin.py", line 177 in run
self.dlg.exec_()
Stack Trace
QgsCustomization::preNotify :
QObject::event :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QCoreApplicationPrivate::sendPostedEvents :
qt_plugin_query_metadata :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QDialog::exec :
PyInit_QtWidgets :
PyArg_ParseTuple_SizeT :
PyEval_EvalFrameDefault :
PyFunction_Vectorcall :
PyFloat_FromDouble :
PyVectorcall_Call :
PyObject_Call :
PyInit_QtCore :
PyInit_QtCore :
PyInit_QtCore :
PyInit_QtCore :
QObject::qt_static_metacall :
QAction::activate :
QMenu::actionGeometry :
QMenu::actionGeometry :
QMenu::mouseReleaseEvent :
QWidget::event :
QMenu::event :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QApplicationPrivate::sendMouseEvent :
QSizePolicy::QSizePolicy :
QSizePolicy::QSizePolicy :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QGuiApplicationPrivate::processMouseEvent :
QWindowSystemInterface::sendWindowSystemEvents :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QCoreApplication::exec :
main :
BaseThreadInitThunk :
RtlUserThreadStart :
QGIS Info
QGIS Version: 3.32.2-Lima
QGIS code revision: c0b8833964
Compiled against Qt: 5.15.3
Running against Qt: 5.15.3
Compiled against GDAL: 3.7.1
Running against GDAL: 3.7.1
System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 10.0.19045
Any chance for you having a look into the matter?
Hi, I am trying to use nnjoin to solve the following task.
There are three layers:
Thanks a lot.
When trying to work on selected features in QGIS 2.99, NNJoin fails with the following error message:
AttributeError: 'QgsVectorLayer' object has no attribute 'selectedFeaturesIterator'
I have two point layers that I want to connect with columnsID data to link to each other with a line.
But QGIS crasches as soon as I press OK to run the process, I have tried with QGIS v 2.18.2 on both Mac and Windows and I have same problems. Anyone else seen this?
Regards
Soren
If Qt4 libraries are not available, the plugin will not start due to import errors.
Creaing an index for the join layer can be time consuming. A progressbar would be used for this task.
If the layer CRS authid() function returns a "USER" code, the generated layer will get that code as its CRS, and that kind of projection information is not used by QGIS.
In such cases, the PROJ4 string could be used instead.
I tried the NNJoin plugin on OSM data transformed to EPSG:23700 CRS.
I would like to join fuels (points) to roads (linestring), but the points' place in the output didn't change. The distance field is correct by the way. What can be the problem?
Hi,
Love the plugin!! I am using the plugin with QGIS 2.18.6 on a Dell 27 inch 5K monitor with Windows 10 and the plugin does not display correctly. It appears that it does not scale the bounding boxes for the text (see image).
I am guessing that the issue relates to the scaling of the text elements that is done by windows for high resolution monitors, I have scaling set to 200% most of the time.
Thanks!!
Nigel
I'm trying to run NNjoin plugin to compute nearest distance between my plot and buildings (urban) but I'm having this error :
Report Details Python Stack Trace ``` Windows fatal exception: access violation Current thread 0x000067a8 (most recent call first): File "C:\Users/germa/AppData/Roaming/QGIS/QGIS3\profiles\nnjoin/python/plugins\NNJoin\NNJoin_plugin.py", line 177 in run self.dlg.exec_() ``` Stack Trace QgsCustomization::preNotify : QObject::event : QApplicationPrivate::notify_helper : QApplication::notify : QgsApplication::notify : QCoreApplication::notifyInternal2 : QCoreApplicationPrivate::sendPostedEvents : qt_plugin_query_metadata : QEventDispatcherWin32::processEvents : qt_plugin_query_metadata : QEventLoop::exec : QDialog::exec : PyInit_QtWidgets : PyArg_ParseTuple_SizeT : PyEval_EvalFrameDefault : PyFunction_Vectorcall : PyFloat_FromDouble : PyVectorcall_Call : PyObject_Call : PyInit_QtCore : PyInit_QtCore : PyInit_QtCore : PyInit_QtCore : QObject::qt_static_metacall : QAction::activate : QAbstractButton::click : QAbstractButton::mouseReleaseEvent : QToolButton::mouseReleaseEvent : QWidget::event : QApplicationPrivate::notify_helper : QApplication::notify : QgsApplication::notify : QCoreApplication::notifyInternal2 : QApplicationPrivate::sendMouseEvent : QSizePolicy::QSizePolicy : QSizePolicy::QSizePolicy : QApplicationPrivate::notify_helper : QApplication::notify : QgsApplication::notify : QCoreApplication::notifyInternal2 : QGuiApplicationPrivate::processMouseEvent : QWindowSystemInterface::sendWindowSystemEvents : QEventDispatcherWin32::processEvents : qt_plugin_query_metadata : QEventLoop::exec : QCoreApplication::exec : main : BaseThreadInitThunk : RtlUserThreadStart : ``` **QGIS Info** QGIS Version: 3.34.0-Prizren QGIS code revision: ffbdd67881 Compiled against Qt: 5.15.3 Running against Qt: 5.15.3 Compiled against GDAL: 3.7.2 Running against GDAL: 3.7.2 **System Info** CPU Type: x86_64 Kernel Type: winnt Kernel Version: 10.0.22621
Here are my files(maybe not projected yet but it should be in ESPG 23839)
Hello,
For a vector layer of "PointZ" type a Python error ("name 'showError' is not defined") is generated. I was able to fix it by changing line 570 in NNJoin_gui.py (else: in getwkbtext) from showError(...) to _self._showError(...).
Would it make sense to include PointZ in the list of supported types, and issue a warning that the z coordinate will be ignored?
Joerg
If one of the attributes in the input layer has the name "distance", the join distance will not be available in the output layer.
When I run a large spatial point to polygon join of 2 million points to 657 polygons using NNjoin, when the process completes and the status bar shows 100%, the NNjoin window does not close and no output file is created or added to QGIS, even after waiting an hour. If I close the status bar on QGIS, I get a Python error "RuntimeError: wrapped C/C++ object of type QProgressBar has been deleted.
NNjoin works fine on smaller point files of tens of thousands rather than millions. Will it work for these larger files?
I really think your plugin should become a core algorithm of Processing (yeah I now it's not the first time I'm saying this :P )
Is it possible to call the plugin programmatically from the Python Console?
Hi,
there is an error everytime we use NNjoin.
File "C:/Users/....\NNJoin_gui.py", line 367, in layerlistchanged
QMessageBox.information(None,
NameError: name 'QMessageBox' is not defined
Does anyone know what record will be chosen when using NN Join in QGIS when joining a polygon layer to a point layer with one-to-many cardinality?
I am joining a point layer to a polygon layer. The points layer are well test results with dates and concentration readings. I only want the oldest test result to be joined to the polygon it falls inside of but I'm not sure how NN Join selects which point will be joined to the polygon. Please help if you know!
Hi
have you a issue for me ?
after install NNjoin on Ubuntu 22.04 and QGIS 3.22, when i click on icon
`Une erreur est survenue lors de l'éxécution du code Python:
TypeError: setValue(self, int): argument 1 has unexpected type 'float'
Traceback (most recent call last):
File "/home/laurent/.local/share/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/NNJoin_plugin.py", line 139, in run
self.dlg.progressBar.setValue(0.0)
TypeError: setValue(self, int): argument 1 has unexpected type 'float'
Version de Python : 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
Version de QGIS : 3.22.4-Białowieża Białowieża, exported `
LJ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.