postgis/loader/README.shp2pgsql
Markus Schaber a4b120b53a added -p option (prepare mode) that spits out the table schema without
inserting any data.


git-svn-id: http://svn.osgeo.org/postgis/trunk@1600 b70326c6-7e19-0410-871a-916f4a2858ee
2005-04-06 14:02:08 +00:00

77 lines
2.6 KiB
Plaintext

shp2pgsql - Convert Shape file to PostGIS
~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VERSION: 0.7 (2002/05/04)
MORE INFORMATION: http://postgis.refractions.net
INTRODUCTION:
This program takes in ESRI shape files and output formatted text suitable
for uploading to the PostGIS/PostgreSQL spatial database using the psql
terminal monitor.
This application uses functionality from shapelib 1.2.9
by Frank Warmerdam <warmerda@gdal.velocet.ca> to read from ESRI
Shape files.
INSTALLATION:
To build shp2pgsql just run 'make'.
Copy the binary wherever you like. :)
USAGE:
shp2pgsql [<options>] <shapefile> <tablename> <database name>
The <shapefile> is the name of the shape file, without any extension
information. For example, 'roads' would be the name of the shapefile
comprising the 'roads.shp', 'roads.shx', and 'roads.dbf' files.
The <tablename> is the name of the database table you want the data stored
in in the database. Within that table, the geometry will be placed in
the 'geo_value' column by default.
The <database name> is the name of the database you are going to put the
the data into.
The options are as follows:
(-a || -c || -d || -p) these options are mutually exclusive.
-a Append mode. Do not delete the target table or try to create
a new table, simple insert the data into the existing table.
A table will have to exist for this to work, it is usually
used after a create mode as been run once or after -p. (mutually
exclusive with -c, -d and -p)
-c Create mode. This is the default mode is no other is specified.
Create a new table and upload the data into that table.
(mutually eclusive with -a, -d and -p)
-d Delete mode. Delete the database table named <tablename>, then
create a new one with that name before uploading the data into
the new empty database table. (mutually exclusive with -a, -c
and -p)
-p Prepare mode. Read the table schema from the shape file and
create the new table, but do not insert any data. (mutually
exclusive with -a, -c and -d)
-D Dump. When inserting the data into the table use 'dump' format.
Dump format is used by PostgreSQL for large data dumps and
uploads. Use this mode if your upload dataset is very large.
(you may still specify -a,-c or -d in conjunction with -D)
EXAMPLES:
Loading directly:
shp2pgsql -c roads1 roads_table my_db | psql -d my_db
shp2pgsql -a roads2 roads_table my_db | psql -d my_db
Saving to an intermiate file using the 'dump' format:
shp2pgsql -D roads1 roads_table my_db > roads.sql
psql -d my_db -f roads.sql