v.what.vect.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env python
  2. #
  3. ############################################################################
  4. #
  5. # MODULE: v.what.vect
  6. # AUTHOR(S): Markus Neteler, converted to Python by Glynn Clements
  7. # PURPOSE: Uploads attributes at the location of vector points to the table.
  8. # COPYRIGHT: (C) 2005, 2008 by the GRASS Development Team
  9. #
  10. # This program is free software under the GNU General Public
  11. # License (>=v2). Read the file COPYING that comes with GRASS
  12. # for details.
  13. #
  14. #############################################################################
  15. #%Module
  16. #% description: Uploads vector values at positions of vector points to the table.
  17. #% keywords: vector
  18. #% keywords: database
  19. #% keywords: attribute table
  20. #%End
  21. #%option
  22. #% key: vector
  23. #% type: string
  24. #% key_desc: name
  25. #% gisprompt: old,vector,vector
  26. #% description: Vector map to modify
  27. #% required : yes
  28. #%end
  29. #%option
  30. #% key: layer
  31. #% type: integer
  32. #% description: Layer in the vector to be modified
  33. #% answer: 1
  34. #% required : no
  35. #%end
  36. #%option
  37. #% key: column
  38. #% type: string
  39. #% description: Column to be updated with the query result
  40. #% required : yes
  41. #%end
  42. #%option
  43. #% key: qvector
  44. #% type: string
  45. #% key_desc: name
  46. #% gisprompt: old,vector,vector
  47. #% description: Vector map to be queried
  48. #% required : yes
  49. #%end
  50. #%option
  51. #% key: qlayer
  52. #% type: integer
  53. #% description: Layer of the query vector containing data
  54. #% answer: 1
  55. #% required : no
  56. #%end
  57. #%option
  58. #% key: qcolumn
  59. #% type: string
  60. #% description: Column to be queried
  61. #% required : yes
  62. #%end
  63. #%option
  64. #% key: dmax
  65. #% type: double
  66. #% description: Maximum query distance in map units
  67. #% answer: 0.0
  68. #% required: no
  69. #%end
  70. import sys
  71. from grass.script import core as grass
  72. def main():
  73. grass.exec_command(
  74. "v.distance",
  75. _from = options['vector'],
  76. to = options['qvector'],
  77. column = options['column'],
  78. to_column = options['qcolumn'],
  79. upload = "to_attr",
  80. dmax = options['dmax'],
  81. from_layer = options['layer'],
  82. to_layer = options['qlayer'])
  83. if __name__ == "__main__":
  84. options, flags = grass.parser()
  85. main()