I had recently removed QGIS 2.14 and then I installed QGIS 2.18 through OSGeo installer. Since then I have noticed problems with the function Join by Attributes in QGIS standalone script. Despite the fact all features in the input layer should be present in the output layer, the output layer is incomplete. It means that the output layer contains always only 1 feature. I tested that function on different data including the layers that had worked fine with installed QGIS 2.14. There are not any error notifications though. The code is as follows:

# -*- coding: utf-8 -*-
from qgis.core import *
from qgis.utils import *
import os, sys

QgsApplication.setPrefixPath("C:/OSGeo4W64/apps/qgis", True)
app = QApplication([], True)

from processing.core.Processing import Processing
from processing.tools import *


layer1 = "D:\\point_shapefile.shp"
layer2 = "D:\\polygon_shapefile.shp"
result = "D:\\output_shapefile.shp"

general.runalg("qgis:joinattributesbylocation", layer1, layer2, u'intersects', 0, 0, '', 1, result)

Although it works as a charm, if I run a script in a QGIS window with the same data:

import processing
layer1 = "D:\\point_shapefile.shp"
layer2 = "D:\\polygon_shapefile.shp"
result = "D:\\output_shapefile.shp"

How could I resolve the problem with incomplete output layer from QGIS standalone script?

I would like to avoid downgrading to QGIS 2.14.

UPDATE (09.11.2016):

I decided to report that issue on the site


Can confirm that the Join attributes by location tool works with your standalone code using the latest QGIS 2.18.13-1 from the OSGeo4W installer.

Note that the bug report you submitted has been closed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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