t.vect.extract.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.vect.extract
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: Extract a subset 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: Extracts a subset of a space time vector dataset.
  18. #% keywords: temporal
  19. #% keywords: extract
  20. #%end
  21. #%option G_OPT_STVDS_INPUT
  22. #%end
  23. #%option G_OPT_T_WHERE
  24. #%end
  25. #%option G_OPT_DB_WHERE
  26. #% key: expression
  27. #%end
  28. #%option G_OPT_STVDS_OUTPUT
  29. #%end
  30. #%option G_OPT_V_FIELD
  31. #%end
  32. #%option G_OPT_V_TYPE
  33. #%end
  34. #%option
  35. #% key: base
  36. #% type: string
  37. #% description: Base name of the new created vector maps
  38. #% required: no
  39. #% multiple: no
  40. #%end
  41. #%option
  42. #% key: nprocs
  43. #% type: integer
  44. #% description: The number of v.extract processes to run in parallel. Use only if database backend is used which supports concurrent writing
  45. #% required: no
  46. #% multiple: no
  47. #% answer: 1
  48. #%end
  49. #%flag
  50. #% key: n
  51. #% description: Register empty maps
  52. #%end
  53. import grass.script as grass
  54. import grass.temporal as tgis
  55. from multiprocessing import Process
  56. ############################################################################
  57. def main():
  58. # Get the options
  59. input = options["input"]
  60. output = options["output"]
  61. where = options["where"]
  62. expression = options["expression"]
  63. layer = options["layer"]
  64. type = options["type"]
  65. base = options["base"]
  66. nprocs = int(options["nprocs"])
  67. register_null = flags["n"]
  68. # Make sure the temporal database exists
  69. tgis.init()
  70. tgis.extract_dataset(input, output, "vector", where, expression,
  71. base, nprocs, register_null, layer, type)
  72. ###############################################################################
  73. if __name__ == "__main__":
  74. options, flags = grass.parser()
  75. main()