Trying to run a simple script using qgis:joinbylocation but getting either errors or it's not processing correctly. I don't want to take a summary of the attributes, just the attributes of the first located feature and I want to keep all records. The parameter selections should be correct but it's the sum,mean,min,max,median that's causing problems. I tried removing them but python wasn't too happy. Also (for some reason) python doesn't recognise mean or median but is fine with the other statistical terms.

Any advice please?

##Output=output vector


processing.runalg("qgis:joinbylocation", File_1, File_2, 0, sum,mean,min,max,median, 0, 1, Output)

After typing the following into the Python console:

import processing processing.alghelp("qgis:joinbylocation")

You get this:

ALGORITHM: Join by location
INPUT1 <ParameterVector>
INPUT2 <ParameterVector>
SUMMARY <ParameterSelection>
STATS <ParameterString>
GEOMETRY <ParameterSelection>
KEEP <ParameterSelection>
OUTPUT <OutputVector>

I failed to notice the ParameterString for STATS which basically means to add ' on either side of the term to convert it onto a string, like this: 'sum,mean,min,max,median'.

So now the code is simply:

##Output=output vector

processing.runalg("qgis:joinbylocation", File_1, File_2, 0, '', 0, 1, Output)

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.