t.select.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.select
  6. # AUTHOR(S): Thomas Leppelt, Soeren Gebbert
  7. #
  8. # PURPOSE: Select maps from space time datasets by topological relationships to
  9. # other space time datasets using temporal algebra.
  10. # COPYRIGHT: (C) 2011-2014 by the GRASS Development Team
  11. #
  12. # This program is free software under the GNU General Public
  13. # License (version 2). Read the file COPYING that comes with GRASS
  14. # for details.
  15. #
  16. #############################################################################
  17. #%module
  18. #% description: Select maps from space time datasets by topological relationships to other space time datasets using temporal algebra.
  19. #% keywords: temporal
  20. #% keywords: metadata
  21. #%end
  22. #%option G_OPT_STDS_TYPE
  23. #% guidependency: input
  24. #% guisection: Required
  25. #%end
  26. #%option
  27. #% key: expression
  28. #% type: string
  29. #% description: The temporal mapcalc expression
  30. #% key_desc: expression
  31. #% required : yes
  32. #%end
  33. #%flag
  34. #% key: s
  35. #% description: Activate spatial topology
  36. #%end
  37. import grass.script as grass
  38. import grass.temporal as tgis
  39. import sys
  40. ############################################################################
  41. def main():
  42. expression = options['expression']
  43. spatial = flags["s"]
  44. stdstype = options["type"]
  45. # Check for PLY istallation
  46. try:
  47. import ply.lex as lex
  48. import ply.yacc as yacc
  49. except:
  50. grass.fatal(_("Please install PLY (Lex and Yacc Python implementation) to use the temporal algebra modules."))
  51. tgis.init(True)
  52. p = tgis.TemporalAlgebraParser(run=True, debug=False, spatial = spatial)
  53. p.parse(expression, stdstype, overwrite=grass.overwrite)
  54. if __name__ == "__main__":
  55. options, flags = grass.parser()
  56. sys.exit(main())