[Qgis-developer] error for QGIS tutorials in python - adding rasters to canvas

Martin Dobias wonder.sk at gmail.com
Thu Jan 24 09:56:43 EST 2008


Hi Tim,

thanks for the snippet. I've updated the examples accordingly, I've
also kept the older version for those interested.
http://blog.qgis.org/?q=node/59

Beware - you need most recent SVN trunk since it now contains fixes to
bindings which got broken by the recent merges.

Is there any source of information how does the raster
rendering/handling work now? I was unable to find anything and some of
the terms are quite new to me...

Bye
Martin

2008/1/24 Tim Sutton <tim at linfiniti.com>:
> Hi
>
> Yes the raster API is changed. I dont know the python stuff so well
> but in the case of C++  you would do something like this:
>
> 117        mpRasterLayer->setDrawingStyle(QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR);
> 118        mpRasterLayer->setColorShadingAlgorithm(QgsRasterLayer::PSEUDO_COLOR);
> 119        mpRasterLayer->setContrastEnhancementAlgorithm(
> 120               QgsContrastEnhancement::STRETCH_TO_MINMAX, false);
>
> You will need to translate that to python api but it should be quite
> similar. Take a look at
> http://svn.qgis.org/trac/browser/trunk/qgis/src/core/raster/qgsrasterlayer.h
> for the different drawing styles and shading algorithms you can use.
>
> Regards
>
> Tim
>
> 2008/1/23, Martin Dobias <wonder.sk at gmail.com>:
>
> > 2008/1/23 volkan kepoglu <vkepoglu at gmail.com>:
> > > downloaded QGIS tutorials in python, changed qgis_prefix and runned
> > > 2_basic_main_window and 3_basic_labelling successfully,
> > > but 4_adding_rasters_to_canvas gives the following error;
> > >
> > > vkepoglu at vkepoglu:~/qgis/tutorials/4_adding_rasters_to_canvas$ python
> > > mainwindow.py
> > > Traceback (most recent call last):
> > >   File " mainwindow.py", line 76, in addLayer
> > >     layer.setColorRampingType(QgsRasterLayer.BLUE_GREEN_RED)
> > > AttributeError: setColorRampingType
> >
> > Ah, that will be caused by the recent refactoring of the raster classes.
> > Peter / Tim - can you suggest how to change the code to make it working again?
> >
> > > how can ı fix?
> > > or the most important than to fix this,
> > > how can ı learn to qgis bindings to python.
> > >
> > > where should ı look for reference of python bindings
> > >
> > > http://wiki.qgis.org/qgiswiki/PythonBindings, is there any other references?
> >
> > Today I've updated PythonBindings wiki page with some resources
> > (listed in top part in Using PyQGIS section). Basically it's good to
> > look at QGIS C++ API reference, QGIS blog, tutorials ported to Python
> > and QGIS plugins that have been done already. (all links listed there)
> >
> > Martin
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.qgis.org
> > 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
>


More information about the Qgis-developer mailing list