db.in.ogr.html 1.9 KB

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