-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
v.db.droprow.py
executable file
·60 lines (47 loc) · 1.45 KB
/
v.db.droprow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/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 feature from a vector map through attribute selection.
#% keyword: vector
#% keyword: attribute table
#% keyword: database
#%end
#%option G_OPT_V_INPUT
#%end
#%option G_OPT_V_FIELD
#%end
#%option G_OPT_DB_WHERE
#% required :yes
#%end
#%option G_OPT_V_OUTPUT
#%end
import sys
import grass.script as grass
from grass.exceptions import CalledModuleError
def main():
# delete vectors via reverse selection
try:
grass.run_command('v.extract',
flags='r',
input=options['input'], layer=options['layer'],
output=options['output'], where=options['where'])
except CalledModuleError:
return 1
# write cmd history:
grass.vector_history(map=options['output'])
return 0
if __name__ == "__main__":
options, flags = grass.parser()
sys.exit(main())