QGIS python processing.runalg Clip returns None
Aside of what Joseph mentioned, there is a number of other things you need to keep in mind when clipping from/to memory, so a little check-list for all of you using processing algorithms and memory layers:
- check, that your version of processing plugin is the newest (2.12.2 behaves in a way described by Joseph), update if not.
- Make sure all layers are in the same crs, as is your canvas. Have it explicitly set in code.
- Run your desired algorithm from GUI and check what name does an output have. For example Polish version of QGIS has the output names translated, so I had to put "Przycięte" instead of "Clipped"... Alternatively you can change language to English, which may be safer, to avoid specific characters of your language.
- Have both clip layers loaded onto canvas (use QgsMapLayerRegistry.instance().addMapLayer(layerIHoldInMemory) )
- But the most important part of my solution was: Don't use QGIS versions newer than 2.4. It seems, that there is some sort of problem with processing polygons/lines, it works nicely, but on QGIS 2.2 Valmiera.
In the newer versions of the Processing plugin, it would seem that you can no longer define the name of the output memory layer. The name of the algorithm is used instead (see similar post).
Therefore, you should replace the last section of your code with something similar:
# Clip coastline with the buffer
processing.runandload("qgis:clip", selectedCoastLine, buforSel, None)
layer = QgsMapLayerRegistry.instance().mapLayersByName("Clipped")[0]