[Qgis-developer] Shaded Relief python plugin available pyqgis,org

Andreas Plesch andreasplesch at netscape.net
Fri Sep 18 16:18:59 EDT 2009


Hello qgis developers,

I was looking for a way to compute a shaded relief map from a DEM
without GRASS, and proceeded to use numpy as it was suggested on the
rasterlang plugin web page. After fiddling with the python console in
Qgis, I decided to tackle a plugin and it turned out to be tractable
after getting over all of the windowing code and learning designer. I
send a version of the plugin to Barry Rowlingson because I reuse his
layerAsArray and writeGeoTiff rasterlang functions and he suggested
some improvements. Since the shader plugin is in a usable form now, I
went ahead and made it available on the pyqgis.org repository as
shadedrelief.zip. Please feel free to test it and improve on it.

Apologies for the coding style, this is my first python experiment.

Right now, it would be nice to add a little preview in the dialog to
see the effect of the parameters on the shading. I can see that I
could take a scaled down copy of the array, apply the shading (would
be quick on a 100x100 image), and display that. Presumably on a pixmap
Qlabel, and I found a code fragment which converts a numpy array to a
Qimage, so no file IO would be necessary.

What would be hard for me is to make that work nicely. I envision each
change in the parameters triggers an update of the preview, or to have
a dedicated update preview button. Perhaps this means that the UI is
not a Qdialog anymore. And it presumably requires a Qaction which is
tied to an update function. I would also need to put the shading
itself into a function.

I also would need to load the layer before the ok clicking, presumably
when the dialog is shown or initialized. Hopefully the update would be
fast. Looking at the rastercatalog plugin for its raster previews I
see that it uses threads to generate the previews. Maybe this would be
required here as well.

All this overwhelms my python knowledge and curiosity by a significant
margin at this point. Any pointers or tips welcome,

Andreas




-- 
Andreas Plesch
20 Oxford St.
Cambridge, MA 02138
Tel: 617-495-2356
Fax:617-495-7660


More information about the Qgis-developer mailing list