[GRASS-SVN] r38684 - in grass/branches/develbranch_6/scripts: .
v.db.dropcol v.db.droprow v.db.droptable
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 11 07:50:42 EDT 2009
Author: neteler
Date: 2009-08-11 07:50:41 -0400 (Tue, 11 Aug 2009)
New Revision: 38684
Added:
grass/branches/develbranch_6/scripts/v.db.droprow/
grass/branches/develbranch_6/scripts/v.db.droprow/Makefile
grass/branches/develbranch_6/scripts/v.db.droprow/description.html
grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow
Modified:
grass/branches/develbranch_6/scripts/v.db.dropcol/description.html
grass/branches/develbranch_6/scripts/v.db.droptable/description.html
Log:
+v.db.droprow
Modified: grass/branches/develbranch_6/scripts/v.db.dropcol/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.dropcol/description.html 2009-08-11 11:45:31 UTC (rev 38683)
+++ grass/branches/develbranch_6/scripts/v.db.dropcol/description.html 2009-08-11 11:50:41 UTC (rev 38684)
@@ -26,6 +26,7 @@
<em><a HREF="v.db.addcol.html">v.db.addcol</a></em>,
<em><a HREF="v.db.addtable.html">v.db.addtable</a></em>,
<em><a HREF="v.db.connect.html">v.db.connect</a></em>,
+<em><a HREF="v.db.droprow.html">v.db.droprow</a></em>,
<em><a HREF="v.db.droptable.html">v.db.droptable</a></em>,
<em><a HREF="v.db.select.html">v.db.select</a></em>,
<em><a HREF="v.db.update.html">v.db.update</a></em>
Added: grass/branches/develbranch_6/scripts/v.db.droprow/Makefile
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.droprow/Makefile (rev 0)
+++ grass/branches/develbranch_6/scripts/v.db.droprow/Makefile 2009-08-11 11:50:41 UTC (rev 38684)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.db.droprow
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Property changes on: grass/branches/develbranch_6/scripts/v.db.droprow/Makefile
___________________________________________________________________
Added: svn:eol-style
+ native
Added: grass/branches/develbranch_6/scripts/v.db.droprow/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.droprow/description.html (rev 0)
+++ grass/branches/develbranch_6/scripts/v.db.droprow/description.html 2009-08-11 11:50:41 UTC (rev 38684)
@@ -0,0 +1,53 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.db.droprow</em> removes a vector object (point, line, area, face etc.)
+from a vector map through attribute selection in the table connected
+to the given vector map. It automatically checks the connection for the specified
+layer.
+
+<h2>NOTES</h2>
+
+v.db.droprow is a front-end to <em>v.extract</em> (reverse selection)
+to allow easier usage.
+
+The existing database connection(s) can be verified with <em>v.db.connect</em>.
+
+<h2>EXAMPLES</h2>
+
+Dropping all vector points without elevation attribute (Spearfish data set):<br>
+<div class="code"><pre>
+g.region rast=elevation.10m
+v.random output=rand5k_elev n=5000
+
+v.db.addtable map=rand5k_elev column="elevation double precision"
+v.what.rast vect=rand5k_elev rast=elevation.10m column=elevation
+
+# verify absence of some elevation attributes ("number of NULL attributes"):
+v.univar rand5k_elev type=point column=elevation
+
+# Remove all vector points lacking elevation attribute
+v.db.droprow rand5k_elev output=rand5k_elev_filt where="elevation IS NULL"
+
+# verify:
+v.univar rand5k_elev_filt type=point column=elevation
+
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em><a HREF="db.droptable.html">db.droptable</a></em>,
+<em><a HREF="db.execute.html">db.execute</a></em>,
+<em><a HREF="v.db.addcol.html">v.db.addcol</a></em>,
+<em><a HREF="v.db.addtable.html">v.db.addtable</a></em>,
+<em><a HREF="v.db.connect.html">v.db.connect</a></em>,
+<em><a HREF="v.db.dropcol.html">v.db.dropcol</a></em>,
+<em><a HREF="v.db.droptable.html">v.db.droptable</a></em>,
+<em><a HREF="v.db.select.html">v.db.select</a></em>,
+<em><a HREF="v.db.update.html">v.db.update</a></em>
+
+
+<h2>AUTHOR</h2>
+
+Markus Neteler
+
+<p><i>Last changed: $Date: 2007-12-30 12:48:58 +0100 (Sun, 30 Dec 2007) $</i>
Added: grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow (rev 0)
+++ grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow 2009-08-11 11:50:41 UTC (rev 38684)
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE: v.db.droprow
+# AUTHOR(S): Markus Neteler
+# PURPOSE: interface to v.extract -r to drop ...
+# COPYRIGHT: (C) 2009 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+
+#%Module
+#% description: Removes a vector object (point, line, area, face etc.) from a vector map through attribute selection
+#% keywords: vector, database, attribute table
+#%End
+
+#%option
+#% key: input
+#% type: string
+#% gisprompt: old,vector,vector
+#% key_desc : name
+#% description: Vector map for which to drop vector objects
+#% required : yes
+#%end
+
+#%option
+#% key: output
+#% type: string
+#% gisprompt: new,vector,vector
+#% key_desc : name
+#% description: Name for output vector map
+#% required : yes
+#%end
+
+#%option
+#% key: layer
+#% type: integer
+#% description: Layer of attribute table to use for selection
+#% answer: 1
+#% required : no
+#%end
+
+#%option
+#% key: where
+#% type: string
+#% description: WHERE conditions for vector delete, without 'where' keyword (e.g. elevation IS NULL)
+#% required : yes
+#%end
+
+if [ -z "$GISBASE" ] ; then
+ echo 'You must be in GRASS GIS to run this program' >&2
+ exit 1
+fi
+
+# save command line
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+ CMDLINE="`basename $0`"
+ for arg in "$@" ; do
+ CMDLINE="$CMDLINE \"$arg\""
+ done
+ export CMDLINE
+ exec g.parser "$0" "$@"
+fi
+
+PROG=`basename $0`
+
+# what to do in case of user break:
+exitprocedure()
+{
+ g.message -e 'User break!'
+ exit 1
+}
+# shell check for user break (signal list: trap -l)
+trap "exitprocedure" 2 3 15
+
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+
+# does map exist in CURRENT mapset?
+eval `g.findfile element=vector file=$GIS_OPT_INPUT mapset=$MAPSET`
+if [ ! "$file" ] ; then
+ g.message -e "Vector map <$GIS_OPT_INPUT> not found in current mapset"
+ exit 1
+fi
+
+table=`v.db.connect map=$GIS_OPT_INPUT -g fs=";" | grep -w $GIS_OPT_LAYER | cut -f2 -d";"`
+if [ -z "$table" ] ; then
+ g.message -e 'There is no table connected to the input vector map! Cannot delete any column'
+ exit 1
+fi
+keycol=`v.db.connect -g fs=";" map=$GIS_OPT_INPUT | grep -w $GIS_OPT_LAYER | cut -f3 -d';'`
+database=`v.db.connect -g fs=";" map=$GIS_OPT_INPUT | grep -w $GIS_OPT_LAYER | cut -f4 -d';'`
+driver=`v.db.connect -g fs=";" map=$GIS_OPT_INPUT | grep -w $GIS_OPT_LAYER | cut -f5 -d';'`
+col="$GIS_OPT_COLUMN"
+
+if [ -z "$GRASS_OVERWRITE" ] ; then
+ OVERFLAG="--o"
+fi
+
+# delete vectors via reverse selection
+v.extract -r input=${GIS_OPT_INPUT} layer=$GIS_OPT_LAYER output=${GIS_OPT_OUTPUT} \
+ where="${GIS_OPT_WHERE}" $OVERFLAG 2>&1 | grep -v 'v.extract complete'
+if [ $? -ne 0 ] ; then
+ g.message -e message="Error in 'where' statement"
+ g.region --q vect=${GIS_OPT_OUTPUT}
+ exit 1
+fi
+
+# write cmd history:
+v.support map=${GIS_OPT_INPUT} cmdhist="${CMDLINE}"
+
+exit 0
Property changes on: grass/branches/develbranch_6/scripts/v.db.droprow/v.db.droprow
___________________________________________________________________
Added: svn:executable
+ *
Modified: grass/branches/develbranch_6/scripts/v.db.droptable/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.droptable/description.html 2009-08-11 11:45:31 UTC (rev 38683)
+++ grass/branches/develbranch_6/scripts/v.db.droptable/description.html 2009-08-11 11:50:41 UTC (rev 38684)
@@ -26,6 +26,7 @@
<em><a HREF="v.db.addtable.html">v.db.addtable</a></em>,
<em><a HREF="v.db.connect.html">v.db.connect</a></em>,
<em><a HREF="v.db.dropcol.html">v.db.dropcol</a></em>,
+<em><a HREF="v.db.droprow.html">v.db.droprow</a></em>,
<em><a HREF="v.db.select.html">v.db.select</a></em>,
<em><a HREF="v.db.update.html">v.db.update</a></em>
More information about the grass-commit
mailing list