t.register.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.register
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: Register raster, vector and raster3d maps in a space time datasets
  9. # COPYRIGHT: (C) 2011-2014, Soeren Gebbert and 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: Registers raster, vector and raster3d maps in a space time datasets.
  18. #% keywords: temporal
  19. #% keywords: map management
  20. #% keywords: register
  21. #% overwrite: yes
  22. #%end
  23. #%option G_OPT_STDS_INPUT
  24. #% required: no
  25. #% guisection: Input
  26. #%end
  27. #%option G_OPT_MAP_INPUTS
  28. #% required: no
  29. #% guisection: Input
  30. #%end
  31. #%option G_OPT_MAP_TYPE
  32. #% guidependency: input,maps
  33. #% guisection: Input
  34. #%end
  35. #%option G_OPT_F_INPUT
  36. #% key: file
  37. #% required: no
  38. #% label: Input file with map names, one per line
  39. #% description: Additionally the start time and the end time can be specified per line
  40. #% guisection: Input
  41. #%end
  42. #%option
  43. #% key: start
  44. #% type: string
  45. #% label: Valid start date and time of the first map
  46. #% description: Format absolute time: "yyyy-mm-dd HH:MM:SS +HHMM", relative time is of type integer).
  47. #% required: no
  48. #% multiple: no
  49. #% guisection: Time & Date
  50. #%end
  51. #%option
  52. #% key: end
  53. #% type: string
  54. #% label: Valid end date and time of all map
  55. #% description: Format absolute time: "yyyy-mm-dd HH:MM:SS +HHMM", relative time is of type integer).
  56. #% required: no
  57. #% multiple: no
  58. #% guisection: Time & Date
  59. #%end
  60. #%option
  61. #% key: unit
  62. #% type: string
  63. #% label: Time stamp unit
  64. #% description: Unit must be set in case of relative time stamps
  65. #% required: no
  66. #% multiple: no
  67. #% options: years,months,days,hours,minutes,seconds
  68. #% guisection: Time & Date
  69. #%end
  70. #%option
  71. #% key: increment
  72. #% type: string
  73. #% label: Time increment
  74. #% description: Time increment between maps for valid time interval creation (format absolute: NNN seconds, minutes, hours, days, weeks, months, years; format relative is integer: 5)
  75. #% required: no
  76. #% multiple: no
  77. #% guisection: Time & Date
  78. #%end
  79. #%option G_OPT_F_SEP
  80. #% description: Field separator character of the input file
  81. #% guisection: Input
  82. #%end
  83. #%flag
  84. #% key: i
  85. #% description: Create an interval (start and end time) in case an increment is provided
  86. #% guisection: Time & Date
  87. #%end
  88. import grass.script as grass
  89. import grass.temporal as tgis
  90. ############################################################################
  91. def main():
  92. # Get the options
  93. name = options["input"]
  94. maps = options["maps"]
  95. type = options["type"]
  96. file = options["file"]
  97. separator = grass.separator(options["separator"])
  98. start = options["start"]
  99. end = options["end"]
  100. unit = options["unit"]
  101. increment = options["increment"]
  102. interval = flags["i"]
  103. # Make sure the temporal database exists
  104. tgis.init()
  105. # Register maps
  106. tgis.register_maps_in_space_time_dataset(
  107. type=type, name=name, maps=maps, file=file, start=start, end=end,
  108. unit=unit, increment=increment, dbif=None, interval=interval, fs=separator)
  109. ###############################################################################
  110. if __name__ == "__main__":
  111. options, flags = grass.parser()
  112. try:
  113. tgis.profile_function(main)
  114. except StandardError as e:
  115. grass.fatal(e)