db.in.ogr.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # HINT: if the database contains spatial tables, but you want to import a non-spatial
  30. table, set the environmental variable PG_LIST_ALL_TABLES to YES before importing
  31. db.in.ogr dsn="PG:host=localhost dbname=ecad user=neteler" \
  32. db_table=ecad_verona_tmean output=ecad_verona_tmean
  33. db.select ecad_verona_tmean
  34. db.describe -c ecad_verona_tmean
  35. </pre></div>
  36. <h3>Import XLS file</h3>
  37. To force reading headers, define environmental
  38. variable <tt>OGR_XLS_HEADERS='FORCE'</tt>. Parameter <b>db_table</b>
  39. refers to the list within XLS file.
  40. <div class="code"><pre>
  41. export OGR_XLS_HEADERS='FORCE'
  42. db.in.ogr dsn=address.xls db_table=address_data
  43. </pre></div>
  44. <h2>SEE ALSO</h2>
  45. <em>
  46. <a href="v.in.ogr.html">v.in.ogr</a>,
  47. <a href="v.in.db.html">v.in.db</a>
  48. </em>
  49. <p>
  50. <a href="sql.html">GRASS SQL interface</a>
  51. <h2>AUTHOR</h2>
  52. Markus Neteler
  53. <p>
  54. <i>Last changed: $Date$</i>