comparison of data
Lars Schylberg
larss at fmi.kth.se
Mon Mar 22 10:10:36 EST 1993
In addition to the anwser I gave this morning I came to think about
that I wrote a script a couple of days ago that is something in line
with what your question was. This script goes a little longer and
makes a segmentation to determine how many places that the changes have
occured also. This script uses gawk since my version of
awk couldn't handle multiple arrays.
Lars
Lars Schylberg Email: larss at fmi.kth.se
Dept. of Geodesy and Photogrammetry
Royal Institute of Technology (KTH) Tel. +46 8 790 86 33
S-100 44 STOCKHOLM, SWEDEN Fax. +46 8 790 66 10
#!/bin/sh
#
# simp.diff.sh
#
# Script to calculate object statistics about difference in
# area objects that are generalized from original map to result map
#
# Author: Lars Schylberg ( larss at fmi.kth.se )
# Department of Photogrammetry
# Royal Inst. of Technolgy
# Stockholm, Sweden
#
# Date: 930320
# History of changes:
#
#--------------------------------------------------------------------------
# Check if GRASS is running
#
test "$GISRC" || echo "GRASS is not running" || exit 2
#----------------------------------------------------------------------------
#
# Evaluate arguments
#
if [ $# != 2 ]
then
echo
echo Usage: `basename $0`
echo ' original=mapname '
echo ' result=mapname '
echo
exit 1
fi
#
# Parse input arguments
#
for i do
case $i in
original*)
ORIG=`echo $i | sed s/original=//` ;;
orig*)
ORIG=`echo $i | sed s/orig=//` ;;
o*)
ORIG=`echo $i | sed s/o=//` ;;
result=*)
RESU=`echo $i | sed s/result=//` ;;
resu=*)
RESU=`echo $i | sed s/resu=//` ;;
res=*)
RESU=`echo $i | sed s/res=//` ;;
r=*)
RESU=`echo $i | sed s/r=//` ;;
*)
echo ""
echo "Unrecognized option: $i"
echo 'Options: original=mapname '
echo ' result=mapname '
echo
exit 1
esac
done
#-----------------------------------------------------------------------
# Check the input arguments
eval `g.findfile element=cell file=$ORIG`
if [ ! "$file" ] ; then
echo "$ORIG - cell file not found"
exit 2
fi
eval `g.findfile element=cell file=$RESU`
if [ ! "$file" ] ; then
echo "$RESU - cell file not found"
exit 2
fi
#-----------------------------------------------------------------------
echo "diff = if ( $ORIG != $RESU )" | r.mapcalc 2>/dev/null >/dev/null
r.clump -q i=diff o=diff.cl 2>/dev/null >/dev/null
echo ""
echo "Simplification statistics on file: $RESU"
echo ""
echo "Simpfication changes"
echo "(Number of changes : orig cat -> simp cat : cells)"
r.stats -czq i=diff.cl,$ORIG,$RESU | \
gawk '$1 != 0 { a[$2,$3]++; s[$2,$3] += $4 }
END { for ( k in a ) print a[k], k, s[k] } '
g.remove rast=diff,diff.cl >/dev/null
echo ""
echo "Original Category Statistics"
echo ""
r.stats -qzc i=$ORIG
echo ""
echo "Simplification Category Statistics"
echo ""
r.stats -qzc i=$RESU
More information about the grass-user
mailing list