2

I want to select the features that are not equal. So, I made a selection by location where the geometric predicate is equal and then I thought to invert the selection. Is there any way to invert the selection using PyQGIS?

My code:

import processing
layer1 = processing.getObject('polygon1')
layer2 = processing.getObject('polygon2')

processing.runalg('qgis:selectbylocation', layer2, layer1, u'equals', 0.005,0)

#INVERT SELECTION
3

Assuming layer2 is the layer holding selection, just use:

layer2.invertSelection()

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.