v.db.droprow.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: v.db.droprow
  5. # AUTHOR(S): Markus Neteler
  6. # Pythonized by Martin Landa
  7. # PURPOSE: Interface to v.extract -r to drop ...
  8. # COPYRIGHT: (C) 2009 by the GRASS Development Team
  9. #
  10. # This program is free software under the GNU General Public
  11. # License (>=v2). Read the file COPYING that comes with GRASS
  12. # for details.
  13. #
  14. #############################################################################
  15. #%module
  16. #% description: Removes a vector feature from a vector map through attribute selection.
  17. #% keyword: vector
  18. #% keyword: attribute table
  19. #% keyword: database
  20. #%end
  21. #%option G_OPT_V_INPUT
  22. #%end
  23. #%option G_OPT_V_FIELD
  24. #%end
  25. #%option G_OPT_DB_WHERE
  26. #% required :yes
  27. #%end
  28. #%option G_OPT_V_OUTPUT
  29. #%end
  30. import sys
  31. import grass.script as grass
  32. from grass.exceptions import CalledModuleError
  33. # i18N
  34. import os
  35. import gettext
  36. gettext.install('grassmods', os.path.join(os.getenv("GISBASE"), 'locale'))
  37. def main():
  38. # delete vectors via reverse selection
  39. try:
  40. grass.run_command('v.extract',
  41. flags='r',
  42. input=options['input'], layer=options['layer'],
  43. output=options['output'], where=options['where'])
  44. except CalledModuleError:
  45. return 1
  46. # write cmd history:
  47. grass.vector_history(map=options['output'])
  48. return 0
  49. if __name__ == "__main__":
  50. options, flags = grass.parser()
  51. sys.exit(main())