t.vect.univar.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #% 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. #% guisection: Selection
  31. #% key: twhere
  32. #%end
  33. #%option G_OPT_DB_WHERE
  34. #% guisection: Selection
  35. #%end
  36. #%option G_OPT_V_TYPE
  37. #% options: point,line,boundary,centroid,area
  38. #% multiple: no
  39. #% answer: point
  40. #%end
  41. #%option G_OPT_F_SEP
  42. #% description: Field separator character between the output columns
  43. #% guisection: Formatting
  44. #%end
  45. #%flag
  46. #% key: e
  47. #% description: Calculate extended statistics
  48. #%end
  49. #%flag
  50. #% key: s
  51. #% description: Suppress printing of column names
  52. #% guisection: Formatting
  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["s"]
  67. separator = grass.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()