[Qgis-developer] (python) access to QgsHillshadeRenderer of raster layer ?

Andreas Plesch andreasplesch at gmail.com
Sat Apr 8 14:00:49 PDT 2017


Responding to myself.

It turns out it is possible to use renderer.writeXML to access altitude and
azimuth values:

#r = rasterlayer.renderer()
import PyQt4.QtXml as qx
doc = qx.QDomDocument()
lElement=doc.createElement('rasterlayer') #some required parent tag
r.writeXML(doc, lElement)
rElement=lElement.firstChild().toElement()
azimuth_string=rElement.attribute('azimuth')

Pretty involved but doable. Looks like I get better used to QtXml. It seems
better than python ElementTree anyways.
Or is there another way ?

How 'heavy' is importing QtXml from a Python perspective ? Something to be
avoided ?

Thanks, Andreas

On Sat, Apr 8, 2017 at 4:00 PM, Andreas Plesch <andreasplesch at gmail.com>
wrote:

> I cannot figure how I can access the .altitude() and .azimuth() functions
> of the QgsHillshadeRenderer implementing the QgsRasterRenderer of
> a QgsRasterLayer.
>
> I can get the QgsRasterRenderer via the .renderer() function of the
> QgsRasterLayer and it return the correct 'hillshade' type via .type() but I
> cannot get further.
>
> Any hints ? Do i need to use .writeXML into a Document to get these values
> ?
>
> --
> Andreas Plesch
> 39 Barbara Rd.
> Waltham, MA 02453
>



-- 
Andreas Plesch
39 Barbara Rd.
Waltham, MA 02453
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170408/1e11da74/attachment.html>


More information about the Qgis-developer mailing list