How can I program a raster legend using PyQGIS?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I program a raster legend using PyQGIS?

René Estrella
Hi all.

I'm trying to program a kind of raster layer component using PyQGIS either as a plugin or as a standalone application.  Which classes of QGIS API do you recommend me to use?  Do you suggest me to use QgsColorTable in conjunction with QgsRasterLayer to obtain the symbology of the raster layer and display it in a QgsLegend?  Are there any other classes do I have to know about for this purpose?  Aditionally, if you can direct me to a good documentation resource to learning how to use PyQGIS (very beginner-oriented) I would be very thankful to you.

René Estrella
Reply | Threaded
Open this post in threaded view
|

Re: How can I program a raster legend using PyQGIS?

Martin Dobias
On Jan 15, 2008 9:45 PM, René Estrella <[hidden email]> wrote:
> I'm trying to program a kind of raster layer component using PyQGIS either
> as a plugin or as a standalone application.  Which classes of QGIS API do
> you recommend me to use?  Do you suggest me to use QgsColorTable in
> conjunction with QgsRasterLayer to obtain the symbology of the raster layer
> and display it in a QgsLegend?  Are there any other classes do I have to
> know about for this purpose?  Aditionally, if you can direct me to a good
> documentation resource to learning how to use PyQGIS (very
> beginner-oriented) I would be very thankful to you.

Hi,
I don't get what you mean by "raster layer component"...

However for anything related to rasters start with QgsRasterLayer
class and friends (all the raster-related classes are in qgis sources
directory src/core/raster).

You can't do anything with QgsLegend since it's not a part of QGIS
libraries (it's quite tightly bound to QGIS application itself).

Where to start when trying PyQGIS:
http://wiki.qgis.org/qgiswiki/PythonBindings
http://wiki.qgis.org/qgiswiki/DevelopingPluginsWithPython

Bye
Martin
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: How can I program a raster legend using PyQGIS?

René Estrella
<quote author="René Estrella">

><quote author="Martin Dobias-2">
>On Jan 15, 2008 9:45 PM, René Estrella <perro1255@hotmail.com> wrote:
>> I'm trying to program a kind of raster layer component using PyQGIS either
>> as a plugin or as a standalone application.  Which classes of QGIS API do
>> you recommend me to use?  Do you suggest me to use QgsColorTable in
>> conjunction with QgsRasterLayer to obtain the symbology of the raster layer
>> and display it in a QgsLegend?  Are there any other classes do I have to
>> know about for this purpose?  Aditionally, if you can direct me to a good
>> documentation resource to learning how to use PyQGIS (very
>> beginner-oriented) I would be very thankful to you.

>Hi,
>I don't get what you mean by "raster layer component"...

Hi, Martin.  Thanks so much for your answer.  There's an error in my last post.  I need to develop a raster LEGEND component, not a raster layer component.  Excuse me for that mistake.  What I particularly need is to display several Ascii Grid Rasters in the map canvas of QGIS, and, attached to it a legend component showing the list of layers loaded and for each layer the symbology indicating the colors corresponding to each pixel value of the raster layer.  I mean, something similar to the vector layer legend, where you can categorize the information and assign a color for each category, and things like those.  It seems it's not possible to obtain such a legend for an ascii grid raster layer with the current functionality included in QGIS.  Because of that, I think the only way to do that is to develop a plugin for producing the legend.  Am I right or there is something more I should know about this topic?  Could you give me some guidance to start developing such a component?

Thanks again and best regards.

René Estrella
Reply | Threaded
Open this post in threaded view
|

Re: How can I program a raster legend using PyQGIS?

Tim Sutton
Hi

QgsRasterLayer has a method rasterLayer->getPaletteAsPixmap() which
gets a pixmap with a pallette swatch on it. I dont know if this is
available from the python bindings (I'm guessing it is), or if it
meets your needs...

Regards

Tim

2008/1/16, René Estrella <[hidden email]>:

>
>
>
> >
> >On Jan 15, 2008 9:45 PM, René Estrella <[hidden email]> wrote:
> >> I'm trying to program a kind of raster layer component using PyQGIS
> >> either
> >> as a plugin or as a standalone application.  Which classes of QGIS API do
> >> you recommend me to use?  Do you suggest me to use QgsColorTable in
> >> conjunction with QgsRasterLayer to obtain the symbology of the raster
> >> layer
> >> and display it in a QgsLegend?  Are there any other classes do I have to
> >> know about for this purpose?  Aditionally, if you can direct me to a good
> >> documentation resource to learning how to use PyQGIS (very
> >> beginner-oriented) I would be very thankful to you.
>
> >Hi,
> >I don't get what you mean by "raster layer component"...
>
> Hi, Martin.  Thanks so much for your answer.  There's an error in my last
> post.  I need to develop a raster LEGEND component, not a raster layer
> component.  Excuse me for that mistake.  What I particularly need is to
> display several Ascii Grid Rasters in the map canvas of QGIS, and, attached
> to it a legend component showing the list of layers loaded and for each
> layer the symbology indicating the colors corresponding to each pixel value
> of the raster layer.  I mean, something similar to the vector layer legend,
> where you can categorize the information and assign a color for each
> category, and things like those.  It seems it's not possible to obtain such
> a legend for an ascii grid raster layer with the current functionality
> included in QGIS.  Because of that, I think the only way to do that is to
> develop a plugin for producing the legend.  Am I right or there is something
> more I should know about this topic?  Could you give me some guidance to
> start developing such a component?
>
> Thanks again and best regards.
>
> René Estrella
> --
> View this message in context: http://www.nabble.com/How-can-I-program-a-raster-legend-using-PyQGIS--tp14846130p14881331.html
> Sent from the qgis-developer mailing list archive at Nabble.com.
>
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>


--
Tim Sutton
QGIS Project Steering Committee Member - Release  Manager
Visit http://qgis.org for a great open source GIS
openModeller Desktop Developer
Visit http://openModeller.sf.net for a great open source ecological
niche modelling tool
Home Page: http://tim.linfiniti.com
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: How can I program a raster legend using PyQGIS?

Martin Dobias
In reply to this post by René Estrella
On Jan 16, 2008 3:14 PM, René Estrella <[hidden email]> wrote:
> >Hi,
> >I don't get what you mean by "raster layer component"...
>
> Hi, Martin.  Thanks so much for your answer.  There's an error in my last
> post.  I need to develop a raster LEGEND component, not a raster layer
> component.

Ah ok, now I got it :-)

>  What I particularly need is to
> display several Ascii Grid Rasters in the map canvas of QGIS, and, attached
> to it a legend component showing the list of layers loaded and for each
> layer the symbology indicating the colors corresponding to each pixel value
> of the raster layer.  I mean, something similar to the vector layer legend,
> where you can categorize the information and assign a color for each
> category, and things like those.  It seems it's not possible to obtain such
> a legend for an ascii grid raster layer with the current functionality
> included in QGIS.  Because of that, I think the only way to do that is to
> develop a plugin for producing the legend.  Am I right or there is something
> more I should know about this topic?  Could you give me some guidance to
> start developing such a component?

Sorry I can't give you more guidance since I'm not much an expert to
rasters. Maybe some of our raster experts could give you some hints...

Martin
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer