t.rast.list.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.rast.list
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: List registered maps of a space time raster dataset
  9. # COPYRIGHT: (C) 2011-2017, Soeren Gebbert and 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: Lists registered maps of a space time raster dataset.
  24. #% keyword: temporal
  25. #% keyword: map management
  26. #% keyword: raster
  27. #% keyword: list
  28. #% keyword: time
  29. #%end
  30. #%option G_OPT_STRDS_INPUT
  31. #%end
  32. #%option
  33. #% key: order
  34. #% type: string
  35. #% description: Sort the space time dataset by category
  36. #% guisection: Formatting
  37. #% required: no
  38. #% multiple: yes
  39. #% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,nsres,ewres,cols,rows,number_of_cells,min,max
  40. #% answer: start_time
  41. #%end
  42. #%option
  43. #% key: columns
  44. #% type: string
  45. #% description: Columns to be printed to stdout
  46. #% guisection: Selection
  47. #% required: no
  48. #% multiple: yes
  49. #% options: id,name,creator,mapset,temporal_type,creation_time,start_time,end_time,north,south,west,east,nsres,ewres,cols,rows,number_of_cells,min,max
  50. #% answer: name,mapset,start_time,end_time
  51. #%end
  52. #%option G_OPT_T_WHERE
  53. #% guisection: Selection
  54. #%end
  55. #%option
  56. #% key: method
  57. #% type: string
  58. #% description: Method used for data listing
  59. #% required: no
  60. #% multiple: no
  61. #% options: cols,comma,delta,deltagaps,gran
  62. #% answer: cols
  63. #%end
  64. #%option
  65. #% key: granule
  66. #% type: string
  67. #% description: The granule to be used for listing. The granule must be specified as string eg.: absolute time "1 months" or relative time "1"
  68. #% required: no
  69. #% multiple: no
  70. #%end
  71. #%option G_OPT_F_SEP
  72. #% label: Field separator character between the output columns
  73. #% guisection: Formatting
  74. #%end
  75. #%option G_OPT_F_OUTPUT
  76. #% required: no
  77. #%end
  78. #%flag
  79. #% key: u
  80. #% description: Suppress printing of column names
  81. #% guisection: Formatting
  82. #%end
  83. import grass.script as grass
  84. ############################################################################
  85. def main():
  86. # lazy imports
  87. import grass.temporal as tgis
  88. # Get the options
  89. input = options["input"]
  90. columns = options["columns"]
  91. order = options["order"]
  92. where = options["where"]
  93. separator = grass.separator(options["separator"])
  94. method = options["method"]
  95. granule = options["granule"]
  96. header = flags["u"]
  97. output = options["output"]
  98. # Make sure the temporal database exists
  99. tgis.init()
  100. tgis.list_maps_of_stds("strds", input, columns, order, where, separator,
  101. method, header, granule, outpath=output)
  102. if __name__ == "__main__":
  103. options, flags = grass.parser()
  104. main()