t.rast3d.extract.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.rast3d.extract
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: Extract a subset of a space time raster3d dataset
  9. # COPYRIGHT: (C) 2011 by the GRASS Development Team
  10. #
  11. # This program is free software under the GNU General Public
  12. # License (version 2). Read the file COPYING that comes with GRASS
  13. # for details.
  14. #
  15. #############################################################################
  16. #%module
  17. #% description: Extracts a subset of a space time raster3d dataset.
  18. #% keywords: temporal
  19. #% keywords: extract
  20. #%end
  21. #%option G_OPT_STR3DS_INPUT
  22. #%end
  23. #%option G_OPT_T_WHERE
  24. #%end
  25. #%option
  26. #% key: expression
  27. #% type: string
  28. #% description: The r3.mapcalc expression assigned to all extracted raster3d maps
  29. #% required: no
  30. #% multiple: no
  31. #%end
  32. #%option G_OPT_STR3DS_OUTPUT
  33. #%end
  34. #%option
  35. #% key: base
  36. #% type: string
  37. #% description: Base name of the new created raster3d maps
  38. #% required: no
  39. #% multiple: no
  40. #%end
  41. #%option
  42. #% key: nprocs
  43. #% type: integer
  44. #% description: Number of r3.mapcalc processes to run in parallel
  45. #% required: no
  46. #% multiple: no
  47. #% answer: 1
  48. #%end
  49. #%flag
  50. #% key: n
  51. #% description: Register Null maps
  52. #%end
  53. import grass.script as grass
  54. import grass.temporal as tgis
  55. ############################################################################
  56. def main():
  57. # Get the options
  58. input = options["input"]
  59. output = options["output"]
  60. where = options["where"]
  61. expression = options["expression"]
  62. base = options["base"]
  63. nprocs = int(options["nprocs"])
  64. register_null = flags["n"]
  65. # Make sure the temporal database exists
  66. tgis.init()
  67. tgis.extract_dataset(input, output, "raster3d", where, expression,
  68. base, nprocs, register_null)
  69. if __name__ == "__main__":
  70. options, flags = grass.parser()
  71. main()