7

I would like to run a geometry processing algorithm from the Python console while using the Edit features in-place modifier.

I copied the output from the processing history to see if it works, e.g:

processing.run("native:rotatefeatures", {'INPUT':'/path/to/layer.shp','ANGLE':40,'ANCHOR':None,'OUTPUT':'memory:'})

but wasn't surprised that it didn't. So what's the trick? (if there is one)

I'm on QGIS 3.6

1 Answer 1

6

As far as I can tell, there is no direct API for doing this. But the following works

from processing.gui import AlgorithmExecutor
rotatealg = QgsApplication.processingRegistry().createAlgorithmById('native:rotatefeatures')
layer = iface.activeLayer()
AlgorithmExecutor.execute_in_place(rotatealg, {'ANGLE':40, 'ANCHOR':None, 'INPUT': layer})
1
  • There seems to be a bug in your snipped: 'native:roatefeatures' should be 'native:rotatefeatures' (with 't').
    – Stefan
    Commented Jul 6, 2019 at 21:24

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.