t.vect.export.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.vect.export
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: Export a space time vector dataset.as GRASS specific archive file
  9. # COPYRIGHT: (C) 2011-2017 by the GRASS Development Team
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. #############################################################################
  22. #%module
  23. #% description: Exports a space time vector dataset as GRASS GIS specific archive file.
  24. #% keyword: temporal
  25. #% keyword: export
  26. #% keyword: vector
  27. #% keyword: time
  28. #%end
  29. #%option G_OPT_STVDS_INPUT
  30. #%end
  31. #%option G_OPT_F_OUTPUT
  32. #% description: Name of a space time vector dataset archive
  33. #%end
  34. #%option G_OPT_M_DIR
  35. #% key: directory
  36. #% description: Path to the work directory, default is /tmp
  37. #% required: no
  38. #% answer: /tmp
  39. #%end
  40. #%option
  41. #% key: compression
  42. #% type: string
  43. #% description: Compression method of the tar archive
  44. #% required: no
  45. #% multiple: no
  46. #% options: no,gzip,bzip2
  47. #% answer: bzip2
  48. #%end
  49. #%option
  50. #% key: format
  51. #% type: string
  52. #% label: The export format of a single vector map
  53. #% description: Supported are GML and GPKG via v.out.ogr and the GRASS package format of v.pack
  54. #% required: no
  55. #% multiple: no
  56. #% options: GML,GPKG,pack
  57. #% answer: GML
  58. #%end
  59. #%option G_OPT_T_WHERE
  60. #%end
  61. import grass.script as grass
  62. ############################################################################
  63. def main():
  64. # lazy imports
  65. import grass.temporal as tgis
  66. # Get the options
  67. _input = options["input"]
  68. output = options["output"]
  69. compression = options["compression"]
  70. directory = options["directory"]
  71. where = options["where"]
  72. _format = options["format"]
  73. # Make sure the temporal database exists
  74. tgis.init()
  75. # Export the space time vector dataset
  76. tgis.export_stds(
  77. _input, output, compression, directory, where, _format, "stvds")
  78. ############################################################################
  79. if __name__ == "__main__":
  80. options, flags = grass.parser()
  81. main()