v.db.join.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <h2>DESCRIPTION</h2>
  2. <em>v.db.join</em> joins the content of another table into the connected
  3. attribute table of a vector map.
  4. <h2>NOTES</h2>
  5. <em>v.db.join</em> is a front-end to <em>db.execute</em> to allow easier usage.
  6. The vector attribute table must be stored in a SQL database (SQLite, PostgreSQL,
  7. MySQL, ODBC, ...). The DBF backend is not supported. Tables can be
  8. imported with <em>db.in.ogr</em>.
  9. <p>
  10. The vector map-database connection(s) can be verified with <em>v.db.connect</em>.
  11. <h2>EXAMPLE</h2>
  12. Joining the soil type explanations from table <em>soils_legend</em>
  13. into the Spearfish soils map (<a href="http://www.grassbook.org/examples_menu.php">download legend)</a>:
  14. <div class="code"><pre>
  15. g.copy vect=soils,mysoils
  16. # import legend table
  17. db.in.ogr soils_legend.csv out=soils_legend
  18. # get join column names
  19. v.info -c mysoils
  20. db.describe -c soils_legend
  21. # look at original table
  22. v.db.select mysoils
  23. cat|label
  24. 1|Aab
  25. 2|Ba
  26. 3|Bb
  27. 4|BcB
  28. 5|BcC
  29. ...
  30. # look at legend
  31. db.select soils_legend
  32. db.select soils_legend | head -7
  33. id|shortname|longname
  34. 0|no data|no data
  35. 0|AaB|Alice fine sandy loam, 0 to 6
  36. 0|Ba|Barnum silt loam
  37. 0|Bb|Barnum silt loam, channeled
  38. 0|BcB|Boneek silt loam, 2 to 6
  39. 0|BcC|Boneek silt loam, 6 to 9
  40. ...
  41. # join soils_legend into mysoils attribute table
  42. v.db.join mysoils col=label otable=soils_legend ocol=shortname
  43. # verification of join
  44. v.db.select mysoils
  45. cat|label|id|shortname|longname
  46. 1|Aab|||
  47. 2|Ba|2|Ba|Barnum silt loam
  48. 3|Bb|3|Bb|Barnum silt loam, channeled
  49. 4|BcB|4|BcB|Boneek silt loam, 2 to 6
  50. 5|BcC|5|BcC|Boneek silt loam, 6 to 9
  51. ...
  52. </pre></div>
  53. <h2>SEE ALSO</h2>
  54. <em><a HREF="db.execute.html">db.execute</a></em>,
  55. <em><a HREF="db.in.ogr.html">db.in.ogr</a></em>,
  56. <em><a HREF="v.db.update.html">v.db.update</a></em><br>
  57. <em><a href="sql.html">GRASS SQL interface</a></em>
  58. <h2>AUTHOR</h2>
  59. Markus Neteler
  60. <p><i>Last changed: $Date$</i>