[GRASS-SVN] r34030 - grass/trunk/scripts/d.correlate
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 27 18:57:19 EDT 2008
Author: neteler
Date: 2008-10-27 18:57:19 -0400 (Mon, 27 Oct 2008)
New Revision: 34030
Modified:
grass/trunk/scripts/d.correlate/d.correlate
Log:
in case of (only) two maps, better map name positioning + max value indication
Modified: grass/trunk/scripts/d.correlate/d.correlate
===================================================================
--- grass/trunk/scripts/d.correlate/d.correlate 2008-10-27 22:57:04 UTC (rev 34029)
+++ grass/trunk/scripts/d.correlate/d.correlate 2008-10-27 22:57:19 UTC (rev 34030)
@@ -54,6 +54,11 @@
fi
if [ "$1" != "@ARGS_PARSED@" ] ; then
+ CMDLINE="`basename $0`"
+ for arg in "$@" ; do
+ CMDLINE="$CMDLINE \"$arg\""
+ done
+ export CMDLINE
exec g.parser "$0" "$@"
fi
@@ -96,31 +101,59 @@
exit 1
fi
+# how many cmd line arguments?
+ARGNUM=`echo "$CMDLINE" | tr -s ' ' '\n' | wc -l | awk '{print $1 - 1}'`
+
echo "CORRELATION" | d.text color=white size=4 line=1
colors="red black blue green gray violet"
-line=2
+if [ $ARGNUM -eq 2 ] ; then
+ line=4
+else
+ line=2
+fi
iloop=0
jloop=0
+
+# get max in case of two maps for x, y axis
+eval `r.univar -g $GIS_OPT_LAYER1`
+max_layer1=$max
+eval `r.univar -g $GIS_OPT_LAYER2`
+max_layer2=$max
+
for i in $GIS_OPT_LAYER1 $GIS_OPT_LAYER2 $GIS_OPT_LAYER3 $GIS_OPT_LAYER4
do
iloop=`expr $iloop + 1`
for j in $GIS_OPT_LAYER1 $GIS_OPT_LAYER2 $GIS_OPT_LAYER3 $GIS_OPT_LAYER4 ; do
jloop=`expr $jloop + 1`
if [ "$i" != "$j" -a $iloop -le $jloop ] ; then
- colorstmp1=`echo $colors | cut -d' ' -f1`
- colorstmp2=`echo $colors | cut -d' ' -f2-`
- colors=`echo $colorstmp2 $colorstmp1`
+ colorstmp1=`echo $colors | cut -d' ' -f1`
+ colorstmp2=`echo $colors | cut -d' ' -f2-`
+ colors=`echo $colorstmp2 $colorstmp1`
- echo $i $j | d.text color=`echo $colors | cut -d' ' -f1` size=4 line=$line
- line=`expr $line + 1`
- r.stats -cnA input=$i,$j > "$TMP1"
- m="`awk '$1>max1{max1=$1} $2>max2{max2=$2} min1==0||$1<min1{min1=$1} min2==0||$2<min2{min2=$2} END {print min1,max1,min2,max2}' $TMP1`"
- m1=`echo $m | cut -d' ' -f1`
- m2=`echo $m | cut -d' ' -f2`
- m3=`echo $m | cut -d' ' -f3`
- m4=`echo $m | cut -d' ' -f4`
- awk '{print "move",($1-min1+1)*100.0/(max1-min1+1),($2-min2+1)*100.0/(max2-min2+1);print "draw",($1-min1+1)*100.0/(max1-min1+1),($2-min2+1)*100.0/(max2-min2+1) }' min1=$m1 max1=$m2 min2=$m3 max2=$m4 "$TMP1" | d.graph color=`echo $colors | cut -d' ' -f1`
+ if [ $ARGNUM -eq 2 ] ; then
+ echo $j | d.text color=`echo $colors | cut -d' ' -f1` size=4 at=0,9$line
+ echo $i | d.text color=`echo $colors | cut -d' ' -f1` size=4 at=60,0$line
+ else
+ echo $i $j | d.text color=`echo $colors | cut -d' ' -f1` size=4 line=$line
+ fi
+ line=`expr $line + 1`
+ r.stats -cnA input=$i,$j > "$TMP1"
+ m="`awk '$1>max1{max1=$1} $2>max2{max2=$2} min1==0||$1<min1{min1=$1} min2==0||$2<min2{min2=$2} END {print min1,max1,min2,max2}' $TMP1`"
+ m1=`echo $m | cut -d' ' -f1`
+ m2=`echo $m | cut -d' ' -f2`
+ m3=`echo $m | cut -d' ' -f3`
+ m4=`echo $m | cut -d' ' -f4`
+ awk '{print "move",($1-min1+1)*100.0/(max1-min1+1),($2-min2+1)*100.0/(max2-min2+1);print "draw",($1-min1+1)*100.0/(max1-min1+1),($2-min2+1)*100.0/(max2-min2+1) }' min1=$m1 max1=$m2 min2=$m3 max2=$m4 "$TMP1" | d.graph color=`echo $colors | cut -d' ' -f1`
+ if [ $ARGNUM -eq 2 ] ; then
+ d.graph << EOF
+size 2 2
+move 0 92
+text $max_layer1
+move 90 2
+text $max_layer2
+EOF
+ fi
fi
done
jloop=0
More information about the grass-commit
mailing list