[gdal-dev] Sum pixel values in selected area of an image

Lukasz Tracewski lukasz.tracewski at outlook.com
Thu Oct 2 00:02:00 PDT 2014


Hi,
I only recently started my adventure with GDAL and GIS in general, so please accept my apologies for perhaps maybe the most accurate formulation of the problem. I also did my best to find the answer already on this mailing list and outside, but to no avail - again possibly due to lack of experience. 
Last year Hansen et al. prepared a detailed map, 30 meters resolution, of forest cover for the whole planet. The data is publicly accessible, both for online viewing and download. Both can be found here: http://earthenginepartners.appspot.com/science-2013-global-forest The forest cover images are GeoTIFF and have pixel values in range [0, 100] that describes percentage of forest cover.
I have some georeferenced images that essentially are composed of ones and zeros, e.g.:0 1 1 0 00 1 1 1 00 1 0 0 0...
Those images are in 1000 meters scale and can spawn over whole continents.  My aim is to calculate forest cover for them: wherever the value is "1", this pixel should be added to the forest cover. Say the Hansen image looks like this:10 20 30 40 5010 80 80 0 00 0 0 0 0...
Then rows and column of this images should be multiplied by respective rows and columns of my own image, producing: 0 * 10 + 20 * 1 + 30 * 1 + 40 * 0 + 50 * 0 + 10 * 0 + 80 * 1 + ... = 210
Mind that scale of both images is different, so the example above is actually not accurate. The real calculations should average pixel values, then sum them and then convert to area.
Can anyone point me where to start? Maybe you know of any examples that could give me a hint?

Thanks,Lucas 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20141002/cd04f058/attachment-0001.html>


More information about the gdal-dev mailing list