File: shp2pgsql.1

package info (click to toggle)
postgis 2.3.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 58,660 kB
  • ctags: 10,181
  • sloc: ansic: 132,858; sql: 131,148; xml: 46,460; sh: 4,832; perl: 4,476; makefile: 2,749; python: 1,198; yacc: 442; lex: 131
file content (159 lines) | stat: -rw-r--r-- 5,465 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
.TH "shp2pgsql" "1" "" "" "PostGIS"
.SH "NAME"
.LP 
shp2pgsql - shapefile to postgis loader

.SH "SYNTAX"
.LP 
shp2pgsql [\fIoptions\fR] \fIshapefile\fR [\fIschema\fR\fB.\fR]\fItable\fR

.SH "DESCRIPTION"
.LP 
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.

.SH "OPTIONS"
.LP 
The loader has several operating modes distinguished by command line flags:

(Note that \-a, \-c, \-d and \-p are mutually exclusive.)
.TP 
\fB\-d\fR
Drops the database table before creating a new table with the data in the 
Shape file.
.TP 
\fB\-a\fR
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.
.TP 
\fB\-c\fR
Creates a new table and populates it from the Shape file. This is the default 
mode.
.TP 
\fB\-p\fR
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.
.TP 
\fB\-D\fR
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.
.TP 
\fB\-w\fR
Output WKT format, instead of WKB.  Note that this can
introduce coordinate drifts due to loss of precision.
.TP 
\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 
\fB\-s\fR [<\fIFROM_SRID\fR>:]<\fISRID\fR>
Creates and populates the geometry tables with the specified SRID.
If FROM_SRID is given, the geometries will be reprojected.
Reprojection cannot be used with \-D.
.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 
\fB\-g\fR <\fIgeometry_column\fR>
Specify the name of the geometry column (mostly useful in append mode).
.TP 
\fB\-k\fR
Keep identifiers case (column, schema and attributes). Note that attributes 
in Shapefile are usually all UPPERCASE.
.TP 
\fB\-m\fR <\fIfilename\fR>
Specify a file containing a set of mappings of (long) column names to 10
character DBF column names. The content of the file is one or more lines 
of two names separated by white space and no trailing or leading space:

COLUMNNAME DBFFIELD1\\n
.br
AVERYLONGCOLUMNNAME DBFFIELD2\\n

etc.
.TP 
\fB\-i\fR
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.
.TP 
\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.
.TP 
\fB\-I\fR
Create a GiST index on the geometry column. 
.TP 
\fB\-N\fR <\fIpolicy\fR>
Specify NULL geometries handling policy (insert,skip,abort).
.TP 
\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 
\fB\-?\fR
Display version and usage information.

.SH "INSTALLATION"
.LP
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.

.SH "EXAMPLES"
.LP 
An example session using the loader to create an input file and uploading it 
might look like this:

# \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

.SH "AUTHORS"
.LP
Originally written by Jeff Lounsbury <jeffloun@refractions.net>.
Improved and maintained by Sandro Santilli <strk@kbt.io>.
Includes small contributions and improvements by others.

This application uses functionality from shapelib 1.2.9
by Frank Warmerdam <warmerda@gdal.velocet.ca> to read from ESRI Shape files.

.SH "SEE ALSO"
.LP 
pgsql2shp(1)

More information is available at http://postgis.net