Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need to know the value of the sum of all pixels in a raster. However, in the Statistics section of the Metadata tab in Properties, under Sum of All Cells it always indicates 0.00. I have tried with different raster formats to no avail. What am I doing wrong? How can I get this value?

share|improve this question
I'm interested in your application of this method, if you don't mind sharing. – MLowry Jun 21 '12 at 15:43

3 Answers

I hope I got you right; I tried to reconstruct your problem with an Raster of mine. The sum of all pixels in a raster is the x-pixels*y-pixels, right? This value you can get in 2 ways: 1)Right click on the actual File(a tiff in my case), the detail window should provide this information 2)Inside the Gis click Raster->Miscellaneous->Information. Select your file->edit->ok. Then you should the the two values, that have to be multiplied. The result is the sum of all pixels in a raster.

share|improve this answer

I understood the question as, How do I get sum of all pixel values of a raster? Something like running Statistics on the attributes of a vector. One can do this easily via programming. I can think of another way to do this via QGIS. It would be inefficient and slightly inaccurate, but it will work.

  • Create a point layer representing each pixel of the raster. You can do this via Vector -> Research Tools -> Regular Points. Use number of points as x_size * y_size. So for a raster of 100 px width x 100px height, use 10000. Specify an offset of (pixel resolution)/2 , so you are sampling a the center of the pixel.
  • Next, install the Point Sampling plugin. Using this plugin, you can sample the raster at all of the 10000 points and get an attribute value which is the pixel value.
  • Run Vector -> Analysis -> Basic Statistics on the resulting vector to get the sum.
share|improve this answer

You could use gdalinfo to get the raster statistics, for example:

gdalinfo -stats filename.tif

This will give you the mean pixel value and the raster size in pixels. You could also get this data from the Properties -> Metadata tab.

Then it's a question of arithmetic: mean value x (height in pixels x width in pixels).

Nick.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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