v.db.droprow.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python3
  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. def main():
  34. # delete vectors via reverse selection
  35. try:
  36. grass.run_command(
  37. "v.extract",
  38. flags="r",
  39. input=options["input"],
  40. layer=options["layer"],
  41. output=options["output"],
  42. where=options["where"],
  43. )
  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())