Time series: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
m (→‎Time stamps: help links)
Line 7: Line 7:
=== Common legends for many raster maps ===
=== Common legends for many raster maps ===


* Overall min/max
The general idea is to:
* r.colors rules=
* Calculate the overall min/max covering all maps with "{{cmd|r.info}} -r"
* r.colors rast=
* Create a full-scale color table with "{{cmd|r.colors}} rules=" on the first map
* d.legend range=min,max
* Copy that color table to other maps in the series with "{{cmd|r.colors}} rast="
* ps.map
* Draw legend to color table extent with "{{cmd|d.legend}} range=min,max"
 
Example using [[MODIS#Pathfinder|Pathfinder SST]] data:
 
ALL_MIN=999999
ALL_MAX=-999999
MAP_PATTERN='*.s0451pfv50-sst*degC.q4'
# 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}'`
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 {{cmd|ps.map}} use the '''colortable''' instruction's "range" parameter.


=== Animation ===
=== Animation ===

Revision as of 03:03, 9 November 2008

Time stamps

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 SST data:

ALL_MIN=999999
ALL_MAX=-999999

MAP_PATTERN='*.s0451pfv50-sst*degC.q4'

# 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}'`
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.

Animation

Development