t.vect.univar.py 2.0 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 from the non-null cells 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 from the non-null cells 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_STRDS_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: fs
  41. #% type: string
  42. #% description: Field 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. fs = options["fs"]
  68. # Make sure the temporal database exists
  69. tgis.create_temporal_database()
  70. tgis.print_vector_dataset_univar_statistics(input, twhere, layer, type, column, where, extended, header, fs)
  71. if __name__ == "__main__":
  72. options, flags = grass.parser()
  73. main()