v.db.droprow.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #% keywords: vector
  18. #% keywords: attribute table
  19. #% keywords: 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. def main():
  33. # delete vectors via reverse selection
  34. ret = grass.run_command('v.extract',
  35. flags = 'r',
  36. input = options['input'], layer = options['layer'],
  37. output = options['output'], where = options['where'])
  38. if ret != 0:
  39. return 1
  40. # write cmd history:
  41. grass.vector_history(map = options['output'])
  42. return 0
  43. if __name__ == "__main__":
  44. options, flags = grass.parser()
  45. sys.exit(main())