Changes between Version 13 and Version 14 of Cookbook gdal


Ignore:
Timestamp:
Jan 29, 2010 11:39:33 AM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Cookbook gdal

    v13 v14  
    1010gdal comes with two main tools (executable files), the command files for gdal are in C:\OSGeo4W\share\gdal 
    1111 call >cmd 
    12 {{{C:\OSGeo4W\bin\ogr2ogr 
     12{{{ 
     13C:\OSGeo4W\bin\ogr2ogr 
    1314}}} 
    1415or  
    15 {{{C:\OSGeo4W\bin\ogrinfo 
     16{{{ 
     17C:\OSGeo4W\bin\ogrinfo 
    1618}}} 
    1719 
     
    4648Sometimes 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. 
    4749{{{ 
    48 C:\OSGeo4W\bin\ogr2ogr -f "ESRI Shapefile" C:\base\basesig\essai1.shp PG:"host=locahost user=postgres dbname=CCM password=postgres port=5433" -sql "SELECT gid, the_geom FROM riversegments" 
     50C:\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" 
    4951}}} 
    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]] 
    5653 
    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. ''' 
    5855 
    5956The 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{{{ 
     58ogr2ogr -f "ESRI Shapefile" essai2 PG:"host=locahost user=postgres dbname=CCM password=postgres port=5433" 
     59}}} 
    6160 
    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" 
    6461 
    6562Now 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