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@1).source() All the best, Xav From: [email protected] [mailto:[email protected]] On Behalf Of Xavier Vollenweider Sent: vendredi 9 août 2013 14:18 To: [email protected] 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
_______________________________________________ Qgis-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-user
