3

I would like to join attributes by location using standalone PyQGIS but I'm getting error. I have QGIS 3.16 installed on my machine.

from qgis.core import *

QgsApplication.setPrefixPath("C:/Program Files/QGIS 3.16/apps/qgis", True)
qgs = QgsApplication([], True)
QgsApplication.initQgis()

import processing
from processing.core.Processing import Processing
Processing.initialize()

processing.run("qgis:joinattributesbylocation", {
            'INPUT':'C:/Users/ja/Inne/Desktop/bdot10k_bubd_a/bdot10k_bubd_a.gpkg', 
            'JOIN':'C:/Users/ja/Inne/Desktop/POLSKA/PRG_PunktyAdresowe_POLSKA.shp',
            'PREDICATE':[1,5],
            'JOIN_FIELDS':['PNA','SIMC_id','SIMC_nazwa','ULIC_nazwa','Numer'],
            'METHOD':1,
            'DISCARD_NONMATCHING':True,
            'PREFIX':'',
            'OUTPUT':'C:/Users/ja/Inne/Desktop/projekt2.gpkg'})

And I'm getting the error:

Traceback (most recent call last): File "", line 1, in File "C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python/plugins\processing\tools\general.py", line 108, in run return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context) File "C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python/plugins\processing\core\Processing.py", line 141, in runAlgorithm raise QgsProcessingException(msg) _core.QgsProcessingException: Error: Algorithm qgis:joinattributesbylocation not found

What is the problem?

2
  • What if you try running Processing.updateAlgsList() after Processing.initialize()? Additionally make sure that %QGIS_PATH%\apps\qgis\python\plugins\processing is added to the PYTHON_PATH environment variable.
    – Taras
    Nov 3, 2020 at 7:27
  • I solved that problem, thank you. I have another problem: gis.stackexchange.com/questions/378188/… Nov 3, 2020 at 7:29

2 Answers 2

1

Solution:

I transfered folder "platforms" (C:\Program Files\QGIS 3.16\apps\qt5\plugins\platforms) to:

C:\Program Files\QGIS 3.16\bin

and

C:\Program Files\QGIS 3.16\apps\Python37
0
0

NNJoin

There is a more advanced plug with in QGIS plugin repo called NNJoin which joins two vector layers (the input and the join layer) based on nearest neighbor relationships.

please refer the page NNJoinPlugin

Your Answer

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

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