Changes between Version 13 and Version 14 of Cookbook gdal
- Timestamp:
- Jan 29, 2010 11:39:33 AM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Cookbook gdal
v13 v14 10 10 gdal comes with two main tools (executable files), the command files for gdal are in C:\OSGeo4W\share\gdal 11 11 call >cmd 12 {{{C:\OSGeo4W\bin\ogr2ogr 12 {{{ 13 C:\OSGeo4W\bin\ogr2ogr 13 14 }}} 14 15 or 15 {{{C:\OSGeo4W\bin\ogrinfo 16 {{{ 17 C:\OSGeo4W\bin\ogrinfo 16 18 }}} 17 19 … … 46 48 Sometimes you have more than one geometry field in a table, and ESRI shape can only support one geometry field per shape. Also you may only want a subset of data. In these cases, you will need to select the geometry field to use. The most flexible way to do this is to use the -sql command which will take any sql statement. 47 49 {{{ 48 C:\OSGeo4W\bin\ogr2ogr -f "ESRI Shapefile" C:\base\basesig\essai1 .shpPG:"host=locahost user=postgres dbname=CCM password=postgres port=5433" -sql "SELECT gid, the_geom FROM riversegments"50 C:\OSGeo4W\bin\ogr2ogr -f "ESRI Shapefile" C:\base\basesig\essai1 PG:"host=locahost user=postgres dbname=CCM password=postgres port=5433" -sql "SELECT gid, the_geom FROM riversegments" 49 51 }}} 50 '' Cedric : ne marche pas, j'obtiens un message du type Unable to open datasource with following drivers, celui là on l'a très très souvent''[[BR]] 51 Example snippet converting from PostGIS to KML 52 ogr2ogr -f "KML" neighborhoods.kml PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" -sql "select gid, name, the_geom from neighborhoods" 53 The below outputs the neighborhood table to KML and sets the KML description field to name of neighborhood 54 ogr2ogr -f "KML" neighborhoods.kml PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" neighborhoods -dsco NameField=name 55 Exporting multiple tables from PostGIS using Ogr2Ogr 52 '' Cedric : ne marche pas, j'obtiens un message du type Unable to open datasource with following drivers, celui là on l'a très très souvent, j'ai essayé plusieurs trucs je ne comprends pas, la requete marche dans pgadmin''[[BR]] 56 53 57 One way in which ogr2ogr excels above using the pgsql2shp tool is that ogr2ogr can export multiple tables at once. This is pretty handy for sharing your postgis data with others who do not have a postgis database. 54 ''' One way in which ogr2ogr excels above using the pgsql2shp tool is that ogr2ogr can export multiple tables at once. This is pretty handy for sharing your postgis data with others who do not have a postgis database. ''' 58 55 59 56 The code below will export all your postgis tables out into a folder called mydatadump in ESRI shape (shp) format. 60 ogr2ogr -f "ESRI Shapefile" mydatadump PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" 57 {{{ 58 ogr2ogr -f "ESRI Shapefile" essai2 PG:"host=locahost user=postgres dbname=CCM password=postgres port=5433" 59 }}} 61 60 62 The code below will export all your postgis tables out into a folder called mydatadump in MapInfo .tab format.63 ogr2ogr -f "MapInfo File" mydatadump PG:"host=myhost user=myloginname dbname=mydbname password=mypassword"64 61 65 62 Now most of the time you probably only want to output a subset of your postgis tables rather than all your tables. This code exports only the neighborhoods and parcels tables to a folder called mydatadump in ESRI shapefile format