t.vect.univar.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.vect.univar
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: Calculates univariate statistics of attributes for each registered vector map of a space time vector dataset
  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: Calculates univariate statistics of attributes for each registered vector map of a space time vector dataset
  24. # % keyword: temporal
  25. # % keyword: statistics
  26. # % keyword: vector
  27. # % keyword: time
  28. # %end
  29. # %option G_OPT_STVDS_INPUT
  30. # %end
  31. # %option G_OPT_F_OUTPUT
  32. # % required: no
  33. # %end
  34. # %option G_OPT_V_FIELD
  35. # %end
  36. # %option G_OPT_DB_COLUMN
  37. # % required: yes
  38. # %end
  39. # %option G_OPT_T_WHERE
  40. # % guisection: Selection
  41. # % key: twhere
  42. # %end
  43. # %option G_OPT_DB_WHERE
  44. # % guisection: Selection
  45. # %end
  46. # %option G_OPT_V_TYPE
  47. # % options: point,line,boundary,centroid,area
  48. # % multiple: no
  49. # % answer: point
  50. # %end
  51. # %option G_OPT_F_SEP
  52. # % label: Field separator character between the output columns
  53. # % guisection: Formatting
  54. # %end
  55. # %flag
  56. # % key: e
  57. # % description: Calculate extended statistics
  58. # %end
  59. # %flag
  60. # % key: u
  61. # % description: Suppress printing of column names
  62. # % guisection: Formatting
  63. # %end
  64. import grass.script as grass
  65. ############################################################################
  66. def main():
  67. # lazy imports
  68. import grass.temporal as tgis
  69. # Get the options
  70. input = options["input"]
  71. output = options["output"]
  72. twhere = options["twhere"]
  73. layer = options["layer"]
  74. type = options["type"]
  75. column = options["column"]
  76. where = options["where"]
  77. extended = flags["e"]
  78. header = flags["u"]
  79. separator = grass.separator(options["separator"])
  80. # Make sure the temporal database exists
  81. tgis.init()
  82. if not output:
  83. output = None
  84. if output == "-":
  85. output = None
  86. tgis.print_vector_dataset_univar_statistics(
  87. input, output, twhere, layer, type, column, where, extended, header, separator
  88. )
  89. if __name__ == "__main__":
  90. options, flags = grass.parser()
  91. main()