t.vect.univar.py 2.0 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 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. #% keywords: temporal
  19. #% keywords: statistics
  20. #% keywords: vector
  21. #%end
  22. #%option G_OPT_STVDS_INPUT
  23. #%end
  24. #%option G_OPT_V_FIELD
  25. #%end
  26. #%option G_OPT_DB_COLUMN
  27. #% required: yes
  28. #%end
  29. #%option G_OPT_T_WHERE
  30. #% key: twhere
  31. #%end
  32. #%option G_OPT_DB_WHERE
  33. #%end
  34. #%option G_OPT_V_TYPE
  35. #% options: point,line,boundary,centroid,area
  36. #% multiple: no
  37. #% answer: point
  38. #%end
  39. #%option
  40. #% key: separator
  41. #% type: string
  42. #% description: Separator character between the output columns
  43. #% required: no
  44. #% answer: |
  45. #%end
  46. #%flag
  47. #% key: e
  48. #% description: Calculate extended statistics
  49. #%end
  50. #%flag
  51. #% key: h
  52. #% description: Print column names
  53. #%end
  54. import grass.script as grass
  55. import grass.temporal as tgis
  56. ############################################################################
  57. def main():
  58. # Get the options
  59. input = options["input"]
  60. twhere = options["twhere"]
  61. layer = options["layer"]
  62. type = options["type"]
  63. column = options["column"]
  64. where = options["where"]
  65. extended = flags["e"]
  66. header = flags["h"]
  67. separator = options["separator"]
  68. # Make sure the temporal database exists
  69. tgis.init()
  70. tgis.print_vector_dataset_univar_statistics(
  71. input, twhere, layer, type, column, where, extended, header, separator)
  72. if __name__ == "__main__":
  73. options, flags = grass.parser()
  74. main()