db.in.ogr.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <h2>DESCRIPTION</h2>
  2. <em>db.in.ogr</em> imports attribute tables in various formats as
  3. supported by the <a href="http://www.gdal.org/">OGR library</a>
  4. on the local system (DBF, CSV, PostgreSQL, SQLite, MySQL, ODBC,
  5. etc.). Optionally a unique <b>key</b> (ID) column can be
  6. added to the table.
  7. <h2>EXAMPLES</h2>
  8. <h3>Import CSV file</h3>
  9. Limited type recognition can be done for Integer, Real, String, Date, Time and DateTime
  10. columns through a descriptive file with same name as the CSV file, but .csvt extension
  11. (see details <a href="http://www.gdal.org/drv_csv.html">here</a>).
  12. <div class="code"><pre>
  13. # NOTE: create koeppen_gridcode.csvt first for automated type recognition
  14. db.in.ogr input=koeppen_gridcode.csv output=koeppen_gridcode
  15. db.select table=koeppen_gridcode
  16. </pre></div>
  17. <h3>Import DBF table</h3>
  18. Import of a DBF table with additional unique key column (e.g., needed
  19. for <em><a href="v.in.db.html">v.in.db</a></em>).
  20. <div class="code"><pre>
  21. db.in.ogr input=/path/to/mydata.dbf output=census_raleigh key=myid
  22. db.describe -c census_raleigh
  23. </pre></div>
  24. <h3>Import of a SQLite table</h3>
  25. <div class="code"><pre>
  26. db.in.ogr input=/path/to/sqlite.db db_table=census_raleigh output=census_raleigh
  27. </pre></div>
  28. <h3>Import of a PostgreSQL table</h3>
  29. <div class="code"><pre>
  30. # HINT: if the database contains spatial tables, but you want to import a non-spatial
  31. table, set the environmental variable PG_LIST_ALL_TABLES to YES before importing
  32. db.in.ogr input="PG:host=localhost dbname=ecad user=neteler" \
  33. db_table=ecad_verona_tmean output=ecad_verona_tmean
  34. db.select table=ecad_verona_tmean
  35. db.describe -c ecad_verona_tmean
  36. </pre></div>
  37. <h3>Import XLS file</h3>
  38. To force reading headers, define environmental
  39. variable <tt>OGR_XLS_HEADERS='FORCE'</tt>. Parameter <b>db_table</b>
  40. refers to the list within XLS file.
  41. <div class="code"><pre>
  42. export OGR_XLS_HEADERS='FORCE'
  43. db.in.ogr input=address.xls db_table=address_data
  44. </pre></div>
  45. <h2>SEE ALSO</h2>
  46. <em>
  47. <a href="db.select.html">db.select</a>,
  48. <a href="v.in.ogr.html">v.in.ogr</a>,
  49. <a href="v.in.db.html">v.in.db</a>
  50. </em>
  51. <p>
  52. <a href="sql.html">GRASS SQL interface</a>
  53. <h2>AUTHOR</h2>
  54. Markus Neteler
  55. <p>
  56. <i>Last changed: $Date$</i>