t.select.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #% keyword: temporal
  20. #% keyword: metadata
  21. #% keyword: time
  22. #%end
  23. #%option G_OPT_STDS_TYPE
  24. #% guidependency: input
  25. #% guisection: Required
  26. #%end
  27. #%option
  28. #% key: expression
  29. #% type: string
  30. #% description: The temporal mapcalc expression
  31. #% key_desc: expression
  32. #% required : yes
  33. #%end
  34. #%flag
  35. #% key: s
  36. #% description: Activate spatial topology
  37. #%end
  38. import grass.script as grass
  39. import grass.temporal as tgis
  40. import sys
  41. ############################################################################
  42. def main():
  43. expression = options['expression']
  44. spatial = flags["s"]
  45. stdstype = options["type"]
  46. # Check for PLY istallation
  47. try:
  48. import ply.lex as lex
  49. import ply.yacc as yacc
  50. except:
  51. grass.fatal(_("Please install PLY (Lex and Yacc Python implementation) to use the temporal algebra modules."))
  52. tgis.init(True)
  53. p = tgis.TemporalAlgebraParser(run=True, debug=False, spatial = spatial)
  54. p.parse(expression, stdstype, overwrite=grass.overwrite)
  55. if __name__ == "__main__":
  56. options, flags = grass.parser()
  57. sys.exit(main())