1#!/usr/local/bin/python3.8 2# -*- coding: utf-8 -*- 3############################################################################ 4# 5# MODULE: t.vect.algebra 6# AUTHOR(S): Thomas Leppelt, Soeren Gebbert 7# 8# PURPOSE: Provide temporal vector algebra to perform spatial and temporal operations 9# for space time datasets by topological relationships to other space time 10# datasets. 11# COPYRIGHT: (C) 2014-2017 by the GRASS Development Team 12# 13# This program is free software; you can redistribute it and/or modify 14# it under the terms of the GNU General Public License as published by 15# the Free Software Foundation; either version 2 of the License, or 16# (at your option) any later version. 17# 18# This program is distributed in the hope that it will be useful, 19# but WITHOUT ANY WARRANTY; without even the implied warranty of 20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21# GNU General Public License for more details. 22# 23############################################################################# 24 25#%module 26#% description: Apply temporal and spatial operations on space time vector datasets using temporal vector algebra. 27#% keyword: temporal 28#% keyword: algebra 29#% keyword: vector 30#% keyword: time 31#%end 32 33#%option 34#% key: expression 35#% type: string 36#% description: Spatio-temporal mapcalc expression 37#% key_desc: expression 38#% required : yes 39#%end 40 41#%option 42#% key: basename 43#% type: string 44#% label: Basename of the new generated output maps 45#% description: A numerical suffix separated by an underscore will be attached to create a unique identifier 46#% key_desc: basename 47#% required : yes 48#%end 49 50#%flag 51#% key: s 52#% description: Check the spatial topology of temporally related maps and process only spatially related maps 53#%end 54 55import grass.script 56import sys 57 58def main(): 59 # lazy imports 60 import grass.temporal as tgis 61 62 expression = options['expression'] 63 basename = options['basename'] 64 spatial = flags["s"] 65 stdstype = "stvds" 66 67 # Check for PLY istallation 68 try: 69 import ply.lex as lex 70 import ply.yacc as yacc 71 except: 72 grass.script.fatal(_("Please install PLY (Lex and Yacc Python implementation) to use the temporal algebra modules.")) 73 74 tgis.init(True) 75 p = tgis.TemporalVectorAlgebraParser(run = True, debug=False, spatial = spatial) 76 p.parse(expression, basename, grass.script.overwrite()) 77 78if __name__ == "__main__": 79 options, flags = grass.script.parser() 80 sys.exit(main()) 81 82