wiki:CookBook pgsql2shp

Version 3 (modified by cedric, 15 years ago) (diff)

--

using shp2pgsql

As the rgdal driver fails to load posgres and the solution from roger Bivand does not seem to work we have to find a way to use shape files in postgres

C:\"Program Files"\PostgreSQL\8.4\bin\pgsql2shp --help
RCSID: $Id: pgsql2shp.c 4914 2009-11-27 18:12:43Z pramsey $ RELEASE: 1.4 USE_GEO
S=1 USE_PROJ=1 USE_STATS=1
USAGE: C:\Program Files\PostgreSQL\8.4\bin\pgsql2shp [<options>] <database> [<sc
hema>.]<table>
       C:\Program Files\PostgreSQL\8.4\bin\pgsql2shp [<options>] <database> <que
ry>

OPTIONS:
  -f <filename>  Use this option to specify the name of the file
     to create.
  -h <host>  Allows you to specify connection to a database on a
     machine other than the default.
  -p <port>  Allows you to specify a database port other than the default.
  -P <password>  Connect to the database with the specified password.
  -u <user>  Connect to the database as the specified user.
  -g <geometry_column> Specify the geometry column to be exported.
  -b Use a binary cursor.
  -r Raw mode. Do not assume table has been created by
     the loader. This would not unescape attribute names
     and will not skip the 'gid' attribute.
  -k Keep postgresql identifiers case.
  -? Display this help screen.

ccm21.riversegments_bretagne

C:\"Program Files"\PostgreSQL\8.4\bin\pgsql2shp -f "C:\Documents and Settings\cedric\Mes documents\Migrateur\eda\exports_shape\riversegments_bretagne" -p 5433 -u postgres -P postgres -g the_geom eda2.0 ccm21.riversegments_bretagne

ccm21.catchments_bretagne

C:\"Program Files"\PostgreSQL\8.4\bin\pgsql2shp -f "C:\Documents and Settings\cedric\Mes documents\Migrateur\eda\exports_shape\catchments_bretagne" -p 5433 -u postgres -P postgres -g the_geom eda2.0 ccm21.catchments_bretagne

clc.clipped_bretagne1

C:\"Program Files"\PostgreSQL\8.4\bin\pgsql2shp -f "C:\Documents and Settings\cedric\Mes documents\Migrateur\eda\exports_shape\clipped_bretagne1" -p 5433 -u postgres -P postgres -g the_geom eda2.0 clc.clipped_bretagne1

riversegments_france

A query selecting a reduced area

C:\"Program Files"\PostgreSQL\8.4\bin\pgsql2shp -f "C:\Documents and Settings\cedric\Mes documents\Migrateur\eda\exports_shape\riversegments_france" -p 5433 -u postgres -P postgres -g the_geom eda2.0 "select * from ccm21.riversegments where wso_id in (select wso_id from france.wso where area='France');"