0

I want to do ->Layers Panel -> select Layer -> go to properties -> change style -> changing angle from python .

Please suggest required python api.

  • Welcome to GIS SE! As a new user be sure to take the Tour to learn about our focussed Q&A format. You seem to have already selected your Python API (pyQGIS). For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. – PolyGeo Nov 14 '16 at 9:03
  • I solved this problem anyway. -->>mapcanvas = iface.mapCanvas()-->> n = mapcanvas.layerCount() -->>layers = [mapcanvas.layer(i) for i in range(n)] -->> symbols = layers[0].rendererV2().symbols() -->> sym = symbols[0] -->> sym.setAngle(theta) -- >> layers[0].triggerRepaint() – Arghya Nov 17 '16 at 4:30
  • I've re-opened your question so that you can add that as an answer. – PolyGeo Nov 17 '16 at 4:36
2

I solved the problem this way:

mapcanvas = iface.mapCanvas()
n = mapcanvas.layerCount()
layers = [mapcanvas.layer(i) for i in range(n)] 
symbols = layers[0].rendererV2().symbols() 
sym = symbols[0]
sym.setAngle(theta) # theta is rotate the symbol dynamically
layers[0].triggerRepaint()

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.