t.vect.extract.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: basename
  36. #% type: string
  37. #% label: Basename of the new generated output maps
  38. #% description: A numerical suffix separated by an underscore will be attached to create a unique identifier
  39. #% required: no
  40. #% multiple: no
  41. #% gisprompt:
  42. #%end
  43. #%option
  44. #% key: nprocs
  45. #% type: integer
  46. #% description: The number of v.extract processes to run in parallel. Use only if database backend is used which supports concurrent writing
  47. #% required: no
  48. #% multiple: no
  49. #% answer: 1
  50. #%end
  51. #%flag
  52. #% key: n
  53. #% description: Register empty maps
  54. #%end
  55. import grass.script as grass
  56. import grass.temporal as tgis
  57. from multiprocessing import Process
  58. ############################################################################
  59. def main():
  60. # Get the options
  61. input = options["input"]
  62. output = options["output"]
  63. where = options["where"]
  64. expression = options["expression"]
  65. layer = options["layer"]
  66. type = options["type"]
  67. base = options["basename"]
  68. nprocs = int(options["nprocs"])
  69. register_null = flags["n"]
  70. # Make sure the temporal database exists
  71. tgis.init()
  72. tgis.extract_dataset(input, output, "vector", where, expression,
  73. base, nprocs, register_null, layer, type)
  74. ###############################################################################
  75. if __name__ == "__main__":
  76. options, flags = grass.parser()
  77. main()