[Qgis-user] zonal statistics with multiple bands raster
Xavier Vollenweider
Xavier.Vollenweider at unige.ch
Fri Aug 9 06:06:52 PDT 2013
Dear all,
Some progresses, the following little code does what I need for the first band (i.e. day) I think:
import qgis.analysis
vectorlayer=qgis.utils.iface.mapCanvas().layer(0)
rasterfile = qgis.utils.iface.mapCanvas().layer(1).source()
zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile,str(1))
zonalstats.calculateStatistics(None)
I would like know to loop over the 11117 days with something like:
Day=range(1,11117,1)
for i in Day:
My question is hence: how do I access the other bands?
This doesn't work for instance: rasterfile = qgis.utils.iface.mapCanvas().layer(data at 1).source()
All the best,
Xav
From: qgis-user-bounces at lists.osgeo.org [mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of Xavier Vollenweider
Sent: vendredi 9 août 2013 14:18
To: qgis-user at lists.osgeo.org
Subject: [Qgis-user] zonal statistics with multiple bands raster
Dear all,
I would like to compute zonal statistics from a raster file with multiple bands (11'117 actually). The raster file (.cdf) contains daily rainfall for Kenya from 1983 to present. I need to get the average rainfall for each county.
I know how to do it manually for each band, but doing it on the 11'117 bands is clearly not option...
Could you provide me with a way to automatize it via the python console?
Ideally, I would like the end result should be a shape file with the 11'117 attributes that I will eventually save as a .csv. The goal is to build a panel dataset that I will use in R or Stata.
All the best,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20130809/8791bb00/attachment.html>
More information about the Qgis-user
mailing list