2
# -*- coding: utf-8 -*-
3
############################################################################
5
# MODULE: t.rast3d.algebra
6
# AUTHOR(S): Thomas Leppelt, Soeren Gebbert
8
# PURPOSE: Provide temporal 3D raster algebra to perform spatial an temporal operations
9
# for space time datasets by topological relationships to other space time
11
# COPYRIGHT: (C) 2014 by the GRASS Development Team
13
# This program is free software under the GNU General Public
14
# License (version 2). Read the file COPYING that comes with GRASS
17
#############################################################################
20
#% description: Apply temporal and spatial operations on space time 3D raster datasets using temporal 3D raster algebra.
30
#% description: Algebraic expression for temporal and spatial analysis of space time 3D raster datasets
37
#% label: Basename of the new generated output maps
38
#% description: A numerical suffix separated by an underscore will be attached to create a unique identifier
45
#% description: Number of r3.mapcalc processes to run in parallel
53
#% description: Activate spatial topology
58
#% description: Register Null maps
63
#% description: Use granularity sampling instead of the temporal topology approach
68
import grass.temporal as tgis
72
expression = options['expression']
73
basename = options['basename']
74
nprocs = options["nprocs"]
76
register_null = flags["n"]
77
granularity = flags["g"]
79
# Check for PLY istallation
82
import ply.yacc as yacc
84
grass.script.fatal(_("Please install PLY (Lex and Yacc Python implementation) to use the temporal algebra modules. "
85
"You can use t.rast3d.mapcalc that provides a limited but useful alternative to "
86
"t.rast3d.mapcalc2 without PLY requirement."))
89
p = tgis.TemporalRaster3DAlgebraParser(run = True, debug=False, spatial = spatial, nprocs = nprocs, register_null = register_null)
92
if not p.setup_common_granularity(expression=expression, stdstype = 'str3ds', lexer = tgis.TemporalRasterAlgebraLexer()):
93
grass.script.fatal(_("Unable to process the expression in granularity algebra mode"))
95
p.parse(expression, basename, grass.script.overwrite())
97
if __name__ == "__main__":
98
options, flags = grass.script.parser()