Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

##Test=name
##File_1=file
##File_2=file
##Output=output vector

mean=None
median=None

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

1 Answer 1

up vote 1 down vote accepted

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:

##Test=name
##File_1=file
##File_2=file
##Output=output vector

processing.runalg("qgis:joinbylocation", File_1, File_2, 0, '', 0, 1, Output)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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