2005-04-01 09:38:12 +00:00
|
|
|
.TH "shp2pgsql" "1" "" "" "PostGIS"
|
|
|
|
.SH "NAME"
|
|
|
|
.LP
|
|
|
|
shp2pgsql - shapefile to postgis loader
|
2006-10-11 09:43:29 +00:00
|
|
|
|
2005-04-01 09:38:12 +00:00
|
|
|
.SH "SYNTAX"
|
|
|
|
.LP
|
|
|
|
shp2pgsql [\fIoptions\fR] \fIshapefile\fR [\fIschema\fR\fB.\fR]\fItable\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
|
2005-04-01 09:38:12 +00:00
|
|
|
.SH "DESCRIPTION"
|
|
|
|
.LP
|
2006-10-11 09:43:29 +00:00
|
|
|
The shp2pgsql data loader converts ESRI Shape files into SQL suitable
|
|
|
|
for insertion into a PostGIS/PostgreSQL database.
|
|
|
|
|
|
|
|
Version: 1.1.5 (2006/10/06)
|
|
|
|
|
|
|
|
.SH "USAGE"
|
|
|
|
.LP
|
|
|
|
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 (optionally schema-qualified) 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.
|
2005-04-05 08:00:07 +00:00
|
|
|
|
2005-04-01 09:38:12 +00:00
|
|
|
.SH "OPTIONS"
|
|
|
|
.LP
|
|
|
|
The loader has several operating modes distinguished by command line flags:
|
|
|
|
|
2006-10-11 09:43:29 +00:00
|
|
|
(Note that -a, -c, -d and -p are mutually exclusive.)
|
2005-04-01 09:38:12 +00:00
|
|
|
.TP
|
|
|
|
\fB\-d\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
Drops the database table before creating a new table with the data in the
|
|
|
|
Shape file.
|
2005-04-01 09:38:12 +00:00
|
|
|
.TP
|
|
|
|
\fB\-a\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
Appends data from the Shape file into the database table. Note that to use
|
|
|
|
this option to load multiple files, the files must have the same attributes
|
|
|
|
and same data types.
|
2005-04-01 09:38:12 +00:00
|
|
|
.TP
|
|
|
|
\fB\-c\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
Creates a new table and populates it from the Shape file. This is the default
|
|
|
|
mode.
|
2005-04-06 14:02:08 +00:00
|
|
|
.TP
|
|
|
|
\fB\-p\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
Only produces the table creation SQL code, without adding any actual data.
|
|
|
|
This can be used if you need to completely separate the table creation and
|
|
|
|
data loading steps.
|
2005-04-01 09:38:12 +00:00
|
|
|
.TP
|
|
|
|
\fB\-D\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
Use the PostgreSQL "dump" format for the output data. This can be combined
|
|
|
|
with -a, -c and -d. It is much faster to load than the default "insert" SQL
|
|
|
|
format. Use this for very large data sets.
|
2005-04-01 09:38:12 +00:00
|
|
|
.TP
|
2011-03-18 15:40:31 +00:00
|
|
|
\fB\-w\fR
|
|
|
|
Output WKT format, instead of WKB. Note that this can
|
|
|
|
introduce coordinate drifts due to loss of precision.
|
|
|
|
.TP
|
2011-03-16 19:16:54 +00:00
|
|
|
\fB\-e\fR
|
|
|
|
Execute each statement on its own, without using a transaction.
|
|
|
|
This allows loading of the majority of good data when there are some bad
|
|
|
|
geometries that generate errors. Note that this cannot be used with the
|
|
|
|
-D flag as the "dump" format always uses a transaction.
|
|
|
|
.TP
|
2011-12-21 16:17:55 +00:00
|
|
|
\fB\-s\fR [<\fIFROM_SRID\fR>:]<\fISRID\fR>
|
2005-04-01 09:38:12 +00:00
|
|
|
Creates and populates the geometry tables with the specified SRID.
|
2011-12-21 16:17:55 +00:00
|
|
|
If FROM_SRID is given, the geometries will be reprojected.
|
|
|
|
Reprojection cannot be used with -D.
|
2011-03-18 15:40:31 +00:00
|
|
|
.TP
|
|
|
|
\fB\-G\fR
|
|
|
|
Use the geography type instead of geometry. Geography is used to store
|
|
|
|
lat/lon data. At the moment the only spatial reference supported is 4326.
|
|
|
|
.TP
|
2005-11-24 20:11:05 +00:00
|
|
|
\fB\-g\fR <\fIgeometry_column\fR>
|
|
|
|
Specify the name of the geometry column (mostly useful in append mode).
|
2005-04-01 09:38:12 +00:00
|
|
|
.TP
|
|
|
|
\fB\-k\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
Keep idendifiers case (column, schema and attributes). Note that attributes
|
|
|
|
in Shapefile are usually all UPPERCASE.
|
2005-04-01 09:38:12 +00:00
|
|
|
.TP
|
|
|
|
\fB\-i\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
Coerce all integers to standard 32\-bit integers, do not create 64\-bit
|
|
|
|
bigints, even if the DBF header signature appears to warrant it.
|
|
|
|
.TP
|
|
|
|
\fB\-S\fR
|
|
|
|
Generate simple Geometries instead of MULTIgeometries. Shape files don't
|
|
|
|
differ between LINESTRINGs and MULTILINESTRINGs, so shp2pgsql generates
|
|
|
|
MULTILINESTRINGs by default. This switch will produce LINESTRINGs instead,
|
|
|
|
but shp2pgsql will fail when it hits a real MULTILINESTRING. The same works
|
|
|
|
for POLYGONs vs. MULTIPOLYGONs.
|
2005-04-05 08:00:07 +00:00
|
|
|
.TP
|
2005-10-03 07:53:38 +00:00
|
|
|
\fB\-W\fR <\fIencoding\fR>
|
|
|
|
Specify the character \fIencoding\fR of Shapefile's attributes.
|
|
|
|
If this option is used the output will be encoded in UTF-8.
|
2005-06-16 17:55:58 +00:00
|
|
|
.TP
|
|
|
|
\fB\-I\fR
|
|
|
|
Create a GiST index on the geometry column.
|
2005-11-24 20:11:05 +00:00
|
|
|
.TP
|
|
|
|
\fB\-N\fR <\fIpolicy\fR>
|
|
|
|
Specify NULL geometries handling policy (insert,skip,abort).
|
2006-10-14 14:22:10 +00:00
|
|
|
.TP
|
2011-03-16 19:16:54 +00:00
|
|
|
\fB\-T\fR <\fItablespace\fR>
|
|
|
|
Specify the tablespace for the new table. Indexes will still use the
|
|
|
|
default tablespace unless the -X parameter is also used. The PostgreSQL
|
|
|
|
documentation has a good description on when to use custom tablespaces.
|
|
|
|
.TP
|
|
|
|
\fB\-X\fR <\fItablespace\fR>
|
|
|
|
Specify the tablespace for the new table's indexes. This applies to
|
|
|
|
the primary key index, and the GIST spatial index if -I is also used.
|
|
|
|
.TP
|
2006-10-14 14:22:10 +00:00
|
|
|
\fB\-?\fR
|
|
|
|
Display version and usage information.
|
2005-11-24 20:11:05 +00:00
|
|
|
|
2006-10-11 09:43:29 +00:00
|
|
|
.SH "INSTALLATION"
|
2005-04-06 14:02:08 +00:00
|
|
|
.LP
|
2006-10-11 09:43:29 +00:00
|
|
|
To compile the program from source, simply run "make" in the source directory.
|
|
|
|
Then copy the binary in your shell search path (or wherever you like). This
|
|
|
|
text is also available as a man page in the ../doc/man/ directory, ready for
|
|
|
|
copying it into the manual search path on unixoid systems.
|
2005-04-06 14:02:08 +00:00
|
|
|
|
2005-04-01 09:38:12 +00:00
|
|
|
.SH "EXAMPLES"
|
|
|
|
.LP
|
2006-10-11 09:43:29 +00:00
|
|
|
An example session using the loader to create an input file and uploading it
|
|
|
|
might look like this:
|
2005-04-01 09:38:12 +00:00
|
|
|
|
|
|
|
# \fBshp2pgsql shaperoads roadstable roadsdb > roads.sql\fR
|
|
|
|
.br
|
|
|
|
# \fBpsql \-d roadsdb \-f roads.sql\fR
|
|
|
|
|
|
|
|
A conversion and upload can be done all in one step using UNIX pipes:
|
|
|
|
|
|
|
|
# \fBshp2pgsql shaperoads roadstable roadsdb | psql \-d roadsdb\fR
|
2006-10-11 09:43:29 +00:00
|
|
|
|
2005-04-01 09:38:12 +00:00
|
|
|
.SH "AUTHORS"
|
|
|
|
.LP
|
|
|
|
Originally written by Jeff Lounsbury <jeffloun@refractions.net>.
|
|
|
|
Improved and maintained by Sandro Santilli <strk@refractions.net>.
|
2006-10-11 09:43:29 +00:00
|
|
|
Includes small contributions and improvements by others.
|
2005-04-01 09:38:12 +00:00
|
|
|
|
|
|
|
This application uses functionality from shapelib 1.2.9
|
|
|
|
by Frank Warmerdam <warmerda@gdal.velocet.ca> to read from ESRI Shape files.
|
2006-10-11 09:43:29 +00:00
|
|
|
|
2005-04-01 09:38:12 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.LP
|
|
|
|
pgsql2shp(1)
|
2006-10-11 09:43:29 +00:00
|
|
|
|
|
|
|
More information is available at http://postgis.refractions.net
|