I am working with Qgis and making some analytics of lightdata. I've used these commands:

rasterfile = qgis.utils.iface.mapCanvas().currentLayer().source()
vectorlayer = qgis.utils.iface.mapCanvas().currentLayer()
import qgis.analysis
zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)

When I open the table I get mean, count, sum. What does it mean in this term? count - what is it counting? sum - what is it summarizing? mean - how does it calculate the mean?

enter image description here

1 Answer 1


Based on intuition I would say that the statistics probably represent the following. count is the number of pixels within the "zone", so for instance within the polygons you're aggregating to or something similar. sum is their combined total value. And mean the average for the zone/polygon: sum/count

  • So do you mean with pixels within the "zone" the "lightpoints" within a zone?
    – Textime
    Mar 20, 2014 at 10:17
  • Yes, so the zonal statistics looks at the number of lightpoints which are represented by pixels with a value up to 63 I believe. So it counts the number of pixels within the zone, adds all the values together, and calculates the mean. Mar 20, 2014 at 10:24
  • 2
    Good intuition (and correct). This kind of output in a raster table is standard across every GIS platform I've ever used. 9 times out of 10, however, it's completely useless information.
    – Wes
    Mar 20, 2014 at 15:10
  • Does Qgis count only the bright points between dark and bright? Or does it count all the points which seem to be a little bit bright, then some which are brighter and so on? What do you mean with useless information? How can I do it better and accurate?
    – Textime
    Mar 21, 2014 at 9:39
  • 1
    Yes, so maybe for some more background information on the use of night light data you can consult the paper by Henderson et al. (2012), AER, "Measuring Economic Growth from Outer Space". Mar 21, 2014 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.