[GRASS-CVS] moritz: grass6/scripts/v.rast.stats v.rast.stats, 1.35,
1.36
grass at intevation.de
grass at intevation.de
Thu Dec 6 12:43:28 EST 2007
Author: moritz
Update of /grassrepository/grass6/scripts/v.rast.stats
In directory doto:/tmp/cvs-serv23836
Modified Files:
v.rast.stats
Log Message:
use table currently linked to map at desired layer, not table with same name as map
Index: v.rast.stats
===================================================================
RCS file: /grassrepository/grass6/scripts/v.rast.stats/v.rast.stats,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- v.rast.stats 10 Oct 2007 06:11:21 -0000 1.35
+++ v.rast.stats 6 Dec 2007 17:43:26 -0000 1.36
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh +x
############################################################################
#
@@ -36,6 +36,13 @@
#% required : yes
#%End
#%option
+#% key: layer
+#% type: integer
+#% description: Layer to which the table to be changed is connected
+#% answer: 1
+#% required : no
+#%end
+#%option
#% key: raster
#% type: string
#% key_desc: name
@@ -195,6 +202,12 @@
DB_SQLDRIVER=`v.db.connect -g "$VECTOR" | cut -d' ' -f5`
DB_DATABASE="`v.db.connect -g "$VECTOR" | cut -d' ' -f4`"
+#Find out which table is linked to the vector map on the given layer
+TABLE=`v.db.connect $VECTOR -g | grep -w $GIS_OPT_LAYER | awk '{print $2}'`
+if [ -z "$TABLE" ] ; then
+ g.message -e 'There is no table connected to this map! Run v.db.connect or v.db.addtable first.'
+ exit 1
+fi
BASECOLS="n min max range mean stddev variance cf_var sum"
@@ -291,7 +304,7 @@
colname="${COLPREFIX}_${var}"
fi
- echo "UPDATE $VECTOR SET ${colname}=${value} WHERE cat=$i;" >> "$SQLTMP"
+ echo "UPDATE $TABLE SET ${colname}=${value} WHERE cat=$i;" >> "$SQLTMP"
done
CURRNUM=`expr $CURRNUM + 1`
More information about the grass-commit
mailing list