I'm writing a QGIS plugin using PyQGIS and I have a weird problem.

When executing following line of code:

processing.runandload("qgis:createpointsalonglines", r"Clipped", 1, 1, 0, r"memory:nodes")

Seems like Qgis doesnt allow me to output to a memory layer. The function works fine if I output to a an real (not-memory) layer, but I don't want that).

Why don't I want that? Beceause in that case, I have to create the layer first, and I need to have a path to save it..

The error:

enter image description here

However, with other processing.runandload functions (for example "qgis:clip"or qgis:orientedminimumboundingbox), it works fine with memory layer

For example,

I execute

processing.runandload("qgis:clip", "parallel", "polygon", r"memory:Clipped")


processing.runandload("qgis:orientedminimumboundingbox", "polygon", 1, r"memory:Oriented_MBBox")

without any problem, in the same program.

Anbybody has any idea why the problem occurs with the createpointsalonglines function?

The problem would also be solved if I outputed to a real layer. But in order to create a layer, you have to define the save path... But that doesnt seem like a good option, since I would then have to ask the user to give me a save path first.. Is there a way to create a layer somewhere without having to ask where? Maybe in the plugin folder? But how do I know the path to the plugin folder?


1 Answer 1


You can use None as output parameter. Doing so, QGIS Processing creates a temporary vector file for you:

processing.runandload("qgis:createpointsalonglines", "Clipped" ,100,0,0,None)


res = processing.runalg("qgis:createpointsalonglines", "Clipped" ,100,0,0,None)
iface.addVectorLayer(res['output'],'my points','ogr')

In my case (on a GNU/Linux), the file is temporarily saved at:


Your Answer

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

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