Time series

From GRASS-Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Setting and querying time stamps

Metadata:

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:

 MAP_PATTERN='*.s0451pfv50-sst*degC.q4'
 
 # find overall min/max
 ALL_MIN=999999
 ALL_MAX=-999999
 
 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}'`
 done
 
 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
 EOF
 
 # apply color table to all other maps 
 for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
    r.colors $MAP rast=$FIRST_MAP
 done
 
 # draw
 for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
    d.rast -o $MAP
    d.legend $MAP range=$ALL_MIN,$ALL_MAX
 done
  • For ps.map use the colortable instruction's "range" parameter.

Animations