5

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

3

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})
  • There seems to be a bug in your snipped: 'native:roatefeatures' should be 'native:rotatefeatures' (with 't'). – Stefan Jul 6 at 21:24
  • Thanks. Fixed it. – spatialthoughts Jul 6 at 23:19

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.