1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- ############################################################################
- #
- # MODULE: t.rast.mapcalc
- # AUTHOR(S): Soeren Gebbert
- #
- # PURPOSE: Perform r.mapcalc expressions on maps of sampled space time raster datasets
- # COPYRIGHT: (C) 2012 by the GRASS Development Team
- #
- # This program is free software under the GNU General Public
- # License (version 2). Read the file COPYING that comes with GRASS
- # for details.
- #
- #############################################################################
- #%module
- #% description: Performs r.mapcalc expressions on maps of sampled space time raster datasets.
- #% keywords: temporal
- #% keywords: mapcalc
- #%end
- #%option G_OPT_STRDS_INPUTS
- #%end
- #%option
- #% key: expression
- #% type: string
- #% description: The r.mapcalc expression applied to each time step of the sampled data
- #% required: yes
- #% multiple: no
- #%end
- #%option G_OPT_T_SAMPLE
- #% key: method
- #% answer: during,overlap,contain,equal
- #%end
- #%option G_OPT_STRDS_OUTPUT
- #%end
- #%option G_OPT_R_BASE
- #% required: yes
- #%end
- #%option
- #% key: nprocs
- #% type: integer
- #% description: The number of r.mapcalc processes to run in parallel
- #% required: no
- #% multiple: no
- #% answer: 1
- #%end
- #%flag
- #% key: n
- #% description: Register Null maps
- #%end
- #%flag
- #% key: s
- #% description: Check spatial overlap
- #%end
- from multiprocessing import Process
- import copy
- import grass.script as grass
- import grass.temporal as tgis
- ############################################################################
- def main():
- # Get the options
- inputs = options["inputs"]
- output = options["output"]
- expression = options["expression"]
- base = options["base"]
- method = options["method"]
- nprocs = int(options["nprocs"])
- register_null = flags["n"]
- spatial = flags["s"]
-
- # Create the method list
- method = method.split(",")
-
- # Make sure the temporal database exists
- tgis.create_temporal_database()
-
- tgis.dataset_mapcalculator(inputs, output, "raster", expression, base, method, nprocs, register_null, spatial)
-
- ###############################################################################
- if __name__ == "__main__":
- options, flags = grass.parser()
- main()
|