[GRASS-SVN] r38716 - in grass/trunk/scripts: . v.db.droprow

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 14 04:13:39 EDT 2009


Author: martinl
Date: 2009-08-14 04:13:38 -0400 (Fri, 14 Aug 2009)
New Revision: 38716

Added:
   grass/trunk/scripts/v.db.droprow/
   grass/trunk/scripts/v.db.droprow/Makefile
   grass/trunk/scripts/v.db.droprow/v.db.droprow.html
   grass/trunk/scripts/v.db.droprow/v.db.droprow.py
Modified:
   grass/trunk/scripts/Makefile
Log:
v.db.droprow backported from devbr6, pythonized

Modified: grass/trunk/scripts/Makefile
===================================================================
--- grass/trunk/scripts/Makefile	2009-08-14 03:03:09 UTC (rev 38715)
+++ grass/trunk/scripts/Makefile	2009-08-14 08:13:38 UTC (rev 38716)
@@ -44,6 +44,7 @@
 	v.db.addtable \
 	v.db.join \
 	v.db.dropcolumn \
+	v.db.droprow \
 	v.db.droptable \
 	v.db.renamecolumn \
 	v.db.reconnect.all \

Added: grass/trunk/scripts/v.db.droprow/Makefile
===================================================================
--- grass/trunk/scripts/v.db.droprow/Makefile	                        (rev 0)
+++ grass/trunk/scripts/v.db.droprow/Makefile	2009-08-14 08:13:38 UTC (rev 38716)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.db.droprow
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass/trunk/scripts/v.db.droprow/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-sh
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass/trunk/scripts/v.db.droprow/v.db.droprow.html
===================================================================
--- grass/trunk/scripts/v.db.droprow/v.db.droprow.html	                        (rev 0)
+++ grass/trunk/scripts/v.db.droprow/v.db.droprow.html	2009-08-14 08:13:38 UTC (rev 38716)
@@ -0,0 +1,53 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.db.droprow</em> removes vector object(s) (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$</i>


Property changes on: grass/trunk/scripts/v.db.droprow/v.db.droprow.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass/trunk/scripts/v.db.droprow/v.db.droprow.py
===================================================================
--- grass/trunk/scripts/v.db.droprow/v.db.droprow.py	                        (rev 0)
+++ grass/trunk/scripts/v.db.droprow/v.db.droprow.py	2009-08-14 08:13:38 UTC (rev 38716)
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       v.db.droprow
+# AUTHOR(S):    Markus Neteler
+#               Pythonized by Martin Landa
+# 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
+#% keywords: database
+#% keywords: 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
+
+import sys
+import grass.script as grass
+
+def main():
+    file = grass.find_file(element = 'vector', name = options['input'],
+                           mapset = grass.gisenv()['MAPSET'])['name']
+    
+    if not file:
+        grass.fatal(_("Vector map <%s> not found in current mapset") % \
+                        options['input'])
+    
+    # delete vectors via reverse selection
+    ret = grass.run_command('v.extract',
+                            flags = 'r',
+                            input = options['input'], layer = options['layer'],
+                            output = options['output'], where = options['where'])
+    if ret != 0:
+        grass.fatal(_("Error in 'where' statement"))
+
+    # write cmd history:
+    grass.vector_history(map = options['output'])
+
+    return 0
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    sys.exit(main())


Property changes on: grass/trunk/scripts/v.db.droprow/v.db.droprow.py
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/x-python
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native



More information about the grass-commit mailing list