I have township polygons on a first layer and landmark points on a second layer.

I would like change the color of each township polygons when landmarks points are missing.

I can already select one polygon according its code think to the following script :

import processing
layer = processing.getObject('township')
query = '"code" = 99 '
selection =    layer.getFeatures(QgsFeatureRequest().setFilterExpression(query))
layer.setSelectedFeatures([k.id() for k in selection])

I can also change the color of all polygons :

symbols = layer.rendererV2().symbols()
symbol = symbols[0]

The attribute table of landmark layer contains the numero , geometry and township's code for each mark. Unfortanutaly some geometries are missing !

I need help to make a final script on PyQgis to change the color of only township polygons without landmarks geometry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.