[GIS] Map algebra in QGIS

map-algebrapythonqgisr

How do you calculate standard deviation for each raster if you have set of rasters (100)? I was searching in raster calculator, but I didnt find it. Also google redirect me to using R or python. But I have just started learning.

So is there som easy way? Or I should really start learning python / R.

I have seen one post here. About Grass, but they was calculating stdev. across multiple rasters.

Best Answer

You don't need to write code if you have GDAL installed (if you have QGIS installed that should be the case, but you can install GDAL seperately if you want/need to)

This assumes you want a separate stddev for each image. If you want the stddev across ALL the images, you'll need to do a Raster Merge to combine them into a single raster.

The gdalinfo tool with its-stats option will spit out several summary stats for each band in a raster:-

... snip ...
Band 1 Block=1000x1 Type=Float32, ColorInterp=Undefined
  Min=11.550 Max=26.510 
  Minimum=11.550, Maximum=26.510, Mean=14.233, StdDev=0.837
  NoData Value=-9999
  Metadata:
    STATISTICS_MAXIMUM=26.510000228882
    STATISTICS_MEAN=14.233161129209
    STATISTICS_MINIMUM=11.550000190735
    STATISTICS_STDDEV=0.83723688736979

If you're using Linux, a short script can be set up to extract the STDDEV for mutiple files. In this case I'm running against hundreds of small ascii grid tiles of Open Lidar Data, and getting a separate stddev for each. You can simply change this to *.tiff; GDAL supports lots of raster formats.

#!/bin/bash
for i in $( ls *.asc); do
  gdalinfo -stats $i | grep STDDEV
done

You should be able to do something similar on Windows if you're using that.