I’ve been working on a standalone Python application using the QGIS Processing Framework. For my application, I am supposed to determine average values of a field from a polygonal vector layer along lines in another vector layer.
To accomplish this, I have been using the “qgis:joinattributesbylocation” algorithm with general.runalg()
as follows:
newLayerp = general.runalg("qgis:joinattributesbylocation", line_layer, polygon_region, u'intersects', 2, 1, "mean,max", 1, None)
newLayer = processing.getObject(newLayerp['OUTPUT'])
When I visualize this layer in QGIS, some lines have been assigned NULL
values. I am not having this issue when using Vector->Data Management Tools->Join Attributes by Location.
How can I get the same results from the standalone application as I seem to be getting from the QGIS GUI?
EDIT
I have tried performing an intersection operation between the line layer and the polygon layer, and then performing the same join attributes by location with the intersection layer and the line layer. I don't get any NULL
values anymore, but I'm getting strange values (it is saying the average field value along the length of the line is in the thousands, when all values are less than ten).
Background Information:
The polygonal vector layer’s field consists of values between 0 and 9. The following is the vector layer, colour-coded according to the field I’m using:
The following are the arguments I’m using for the Join Attributes by Location tool in the QGIS GUI:
The following is the result that I get from running the algorithm through the tool in the QGIS GUI, colour-coded by the value of the field I’m using. This is the result that I want to replicate.
I get the following vector layer from my Python code. The lines with NULL
values are marked in black, and these are what I’m hoping to resolve.