Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'd like to change the layer rendering style from python code. Basically I want to do the same operations I can do from QGis by:

  1. Right-click on a layer
  2. Select Properties
  3. Select one of the displayed Saved styles, and Apply changes

I found several examples on the net, but all talks about loading custom styles from files. I don't want (at least for the moment) do that. I need to use already available styles provided from QGis application.

I have a style called 'Construction road' on the property menu, so I tried the following:

aLayer = self.osmNavigator.iface.addVectorLayer(uri.uri(),layerName,self.dbConn.getProviderName())
aLayer.loadNamedStyle("Construction road")

but this doesn't work.

My question are:

  1. How can I change the rendering style of a QGisVectorLayer from a python plugin, selecting one from already available styles?
  2. Can I retrieve a list of all available style names?
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.