Time series

From GRASS-Wiki
Jump to navigation Jump to search

Setting and querying time stamps


Time series in GRASS GIS 7

Raster map time series analysis

  • r.series - module to analyse series of raster maps, considering the stack of input maps along the time axis
  • r.hants (src): performs a harmonic analysis of time series in order to estimate missing values and identify outliers (install with g.extension)
  • r.regression.series (src): module to calculate linear regression parameters between two time series, e.g. NDVI and precipitation (install with g.extension)

Common legends for many raster maps

The general idea is to:

  • Calculate the overall min/max covering all maps with "r.info -r"
  • Create a full-scale color table with "r.colors rules=" on the first map
  • Copy that color table to other maps in the series with "r.colors rast="
  • Draw legend to color table extent with "d.legend range=min,max"

Example using Pathfinder AVHRR SST data:

 # find overall min/max
 for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
   eval `r.info -r $MAP`
   ALL_MAX=`echo "$max $ALL_MAX" | awk '{if ($1 > $2) print $1; else print $2}'`
   ALL_MIN=`echo "$min $ALL_MIN" | awk '{if ($1 < $2) print $1; else print $2}'`
 echo "all_min=$ALL_MIN   all_max=$ALL_MAX"
 ONETHIRD=`echo $ALL_MIN $ALL_MAX | awk '{print ($2 - $1)/3.0 + $1}'`
 TWOTHIRD=`echo $ALL_MIN $ALL_MAX | awk '{print 2*($2 - $1)/3.0 + $1}'` 
 # create full-scale color table for first map
 FIRST_MAP=`g.mlist rast pattern=$MAP_PATTERN | head -n 1`
 r.colors $FIRST_MAP color=rules << EOF
  $ALL_MIN blue
  $ONETHIRD cyan
  $TWOTHIRD yellow
  $ALL_MAX red
 # apply color table to all other maps 
 for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
    r.colors $MAP rast=$FIRST_MAP
 # draw
 for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
    d.rast -o $MAP
    d.legend $MAP range=$ALL_MIN,$ALL_MAX
  • For ps.map use the colortable instruction's "range" parameter.