Take the 2-minute tour ×
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 am implementing a tool which allows an user to calculate some statistics with some data from the registration office. My question is, can I set some layer styles using pyQGIS?

The analysis part is already finished and in a next step I want to laod the layer (which also works perfectly) and visualise it in QGIS. The problem is that I have found until now no way to "say" QGIS that the layer should be visualised by using "graduated colors", a special color ramp and a special classification.

Is there a way to do this using pyQGIS (mayber by using map canavas) or does the user has to do it manually in the layer settings?

Regards from Hamburg,

share|improve this question

1 Answer 1

up vote 2 down vote accepted

My proposal may not be the most efficient but here goes:

You could script the creation of a .qml file (how QGIS stores its default symbolization for layers) with the ramp and classes you require, and save it with the same basename as the layer you are creating. THis would load the file with that symbolization.

Hope this is helpful :) PS: this link may be helpful: How to create a style file for QGIS from a plain text file?

share|improve this answer
    
Thank you! Works very well. –  userHH Sep 11 '12 at 21:12
    
You're very welcome :) –  s_a Sep 11 '12 at 22:03

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.