[postgis-users] ogr2ogr syntax???

Frank Warmerdam warmerdam at pobox.com
Mon Nov 3 10:10:47 PST 2003

Menke, Kurt wrote:
> Hi,
> I am trying to implement ogr2ogr to convert a PostGIS view to a 
> shapefile but cannot find any CLEAR examples of the syntax.  Especially 
> for the arguments:
> -dsco NAME=VALUE: Dataset creation option (format specific)
>  -lco  NAME=VALUE: Layer creation option (format specific)
> Does anyone have good examples of using this command especially 
> specifying a PostgreSQL data source (view) and a path to an output 
> shapefile?


I just tested the following command to dump the poly table in the "test"
Postgres database to a shapefile called p2.shp and it worked fine.

   ogr2ogr p2.shp PG:dbname=test poly

The options available for the -dsco and -lco flags are driver specific.
In the case of the shapefile driver (as noted in the shapefile driver page
under supported formats) there is only one supported option, SHPT to set
the shapefile type.  By default I believe the shapefile type is determined
from the geometry type of the first feature written.  But if you wanted to
force the output to be a 3D polygon shapefile in the above case you might use:

   ogr2ogr p2.shp PG:dbname=test -lco SHPT=POLYGONZ poly

Some drivers, such as the PostGIS one itself, have a substantial list of
layer or even datasource creation options.

Best regards,

I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the postgis-users mailing list