v.what.vect.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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, 2011 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 G_OPT_V_MAP
  22. #% label: Name of vector points map for which to edit attributes
  23. #%end
  24. #%option G_OPT_V_FIELD
  25. #%end
  26. #%option G_OPT_DB_COLUMN
  27. #% description: Name of attribute column to be updated with the query result
  28. #% required: yes
  29. #%end
  30. #%option G_OPT_V_MAP
  31. #% key: qmap
  32. #% label: Name of vector map to be queried
  33. #% required : yes
  34. #%end
  35. #%option G_OPT_V_FIELD
  36. #% key: qlayer
  37. #%end
  38. #%option G_OPT_DB_COLUMN
  39. #% key: qcolumn
  40. #% description: Name of attribute column to be queried
  41. #% required: yes
  42. #%end
  43. #%option
  44. #% key: dmax
  45. #% type: double
  46. #% description: Maximum query distance in map units
  47. #% answer: 0.0
  48. #% required: no
  49. #%end
  50. import sys
  51. from grass.script import core as grass
  52. def main():
  53. return grass.run_command("v.distance",
  54. _from = options['map'],
  55. to = options['qmap'],
  56. column = options['column'],
  57. to_column = options['qcolumn'],
  58. upload = "to_attr",
  59. dmax = options['dmax'],
  60. from_layer = options['layer'],
  61. to_layer = options['qlayer'])
  62. if __name__ == "__main__":
  63. options, flags = grass.parser()
  64. sys.exit(main())