t.vect.univar.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env python
  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-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: Calculates univariate statistics of attributes for each registered vector map of a space time vector dataset
  18. #% keyword: temporal
  19. #% keyword: statistics
  20. #% keyword: vector
  21. #% keyword: time
  22. #%end
  23. #%option G_OPT_STVDS_INPUT
  24. #%end
  25. #%option G_OPT_V_FIELD
  26. #%end
  27. #%option G_OPT_DB_COLUMN
  28. #% required: yes
  29. #%end
  30. #%option G_OPT_T_WHERE
  31. #% guisection: Selection
  32. #% key: twhere
  33. #%end
  34. #%option G_OPT_DB_WHERE
  35. #% guisection: Selection
  36. #%end
  37. #%option G_OPT_V_TYPE
  38. #% options: point,line,boundary,centroid,area
  39. #% multiple: no
  40. #% answer: point
  41. #%end
  42. #%option G_OPT_F_SEP
  43. #% label: Field separator character between the output columns
  44. #% guisection: Formatting
  45. #%end
  46. #%flag
  47. #% key: e
  48. #% description: Calculate extended statistics
  49. #%end
  50. #%flag
  51. #% key: s
  52. #% description: Suppress printing of column names
  53. #% guisection: Formatting
  54. #%end
  55. import grass.script as grass
  56. import grass.temporal as tgis
  57. ############################################################################
  58. def main():
  59. # Get the options
  60. input = options["input"]
  61. twhere = options["twhere"]
  62. layer = options["layer"]
  63. type = options["type"]
  64. column = options["column"]
  65. where = options["where"]
  66. extended = flags["e"]
  67. header = flags["s"]
  68. separator = grass.separator(options["separator"])
  69. # Make sure the temporal database exists
  70. tgis.init()
  71. tgis.print_vector_dataset_univar_statistics(
  72. input, twhere, layer, type, column, where, extended, header, separator)
  73. if __name__ == "__main__":
  74. options, flags = grass.parser()
  75. main()