t.rast.export.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.rast.export
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: Export a space time raster 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: Exports space time raster dataset.
  18. #% keywords: temporal
  19. #% keywords: export
  20. #%end
  21. #%option G_OPT_STRDS_INPUT
  22. #%end
  23. #%option G_OPT_F_OUTPUT
  24. #% description: Name of a space time raster dataset archive
  25. #%end
  26. #%option G_OPT_M_DIR
  27. #% key: workdir
  28. #% description: Path to the work directory, default is /tmp
  29. #% required: no
  30. #% answer: /tmp
  31. #%end
  32. #%option
  33. #% key: compression
  34. #% type: string
  35. #% description: Compression method of the tar archive
  36. #% required: no
  37. #% multiple: no
  38. #% options: no,gzip,bzip2
  39. #% answer: bzip2
  40. #%end
  41. #%option
  42. #% key: format
  43. #% type: string
  44. #% description: The export format of a single raster map. Supported are GTiff, AAIGrid via r.out.gdal and the GRASS package format of r.pack.
  45. #% required: no
  46. #% multiple: no
  47. #% options: GTiff,AAIGrid,pack
  48. #% answer: GTiff
  49. #%end
  50. #%option G_OPT_T_WHERE
  51. #%end
  52. import grass.script as grass
  53. import grass.temporal as tgis
  54. ############################################################################
  55. def main():
  56. # Get the options
  57. _input = options["input"]
  58. output = options["output"]
  59. compression = options["compression"]
  60. workdir = options["workdir"]
  61. where = options["where"]
  62. _format = options["format"]
  63. # Make sure the temporal database exists
  64. tgis.init()
  65. # Export the space time raster dataset
  66. tgis.export_stds(
  67. _input, output, compression, workdir, where, _format, "strds")
  68. ############################################################################
  69. if __name__ == "__main__":
  70. options, flags = grass.parser()
  71. main()