t.rast.export.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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-2014 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. #% keyword: temporal
  19. #% keyword: export
  20. #% keyword: raster
  21. #% keyword: time
  22. #%end
  23. #%option G_OPT_STRDS_INPUT
  24. #%end
  25. #%option G_OPT_F_OUTPUT
  26. #% description: Name of a space time raster dataset archive
  27. #%end
  28. #%option G_OPT_M_DIR
  29. #% key: directory
  30. #% description: Path to the work directory, default is /tmp
  31. #% required: no
  32. #% answer: /tmp
  33. #%end
  34. #%option
  35. #% key: compression
  36. #% type: string
  37. #% description: Compression method of the tar archive
  38. #% required: no
  39. #% multiple: no
  40. #% options: no,gzip,bzip2
  41. #% answer: bzip2
  42. #%end
  43. #%option
  44. #% key: format
  45. #% type: string
  46. #% label: The export format of a single raster map
  47. #% description: Supported are GTiff, AAIGrid via r.out.gdal and the GRASS package format of r.pack
  48. #% required: no
  49. #% multiple: no
  50. #% options: GTiff,AAIGrid,pack
  51. #% answer: GTiff
  52. #%end
  53. #%option
  54. #% key: type
  55. #% type: string
  56. #% label: Data type
  57. #% description: Supported only for GTiff
  58. #% required: no
  59. #% multiple: no
  60. #% options: Byte,Int16,UInt16,Int32,UInt32,Float32,Float64,CInt16,CInt32,CFloat32,CFloat64
  61. #%end
  62. #%option G_OPT_T_WHERE
  63. #%end
  64. import grass.script as grass
  65. import grass.temporal as tgis
  66. ############################################################################
  67. def main():
  68. # Get the options
  69. _input = options["input"]
  70. output = options["output"]
  71. compression = options["compression"]
  72. directory = options["directory"]
  73. where = options["where"]
  74. _format = options["format"]
  75. _type = options["type"]
  76. if _type and _format in ["pack", "AAIGrid"]:
  77. grass.warning(_("Type options is not working with pack format, it will be skipped"))
  78. # Make sure the temporal database exists
  79. tgis.init()
  80. # Export the space time raster dataset
  81. tgis.export_stds(_input, output, compression, directory, where, _format,
  82. "strds", _type)
  83. ############################################################################
  84. if __name__ == "__main__":
  85. options, flags = grass.parser()
  86. main()