mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-23 16:42:35 +00:00
added -S option and updated README to loader/dumper
git-svn-id: http://svn.osgeo.org/postgis/trunk@2503 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
3d1990cfc8
commit
25a72ae95d
3
CHANGES
3
CHANGES
|
@ -5,6 +5,9 @@ PostGIS 1.1.5-CVS
|
|||
- fixed nullpointer Exception in Geometry.equals() method
|
||||
- Added EJB3Spatial.odt to fulfill the GPL requirement of
|
||||
distributing the "preferred form of modification"
|
||||
- Added -S option for non-multi geometries to shp2pgsql
|
||||
- Updated heavily outdated README files for shp2pgsql/pgsql2shp by
|
||||
merging them with the manpages.
|
||||
|
||||
PostGIS 1.1.4
|
||||
|
||||
|
|
|
@ -2,72 +2,96 @@
|
|||
.SH "NAME"
|
||||
.LP
|
||||
pgsql2shp - postgis to shapefile dumper
|
||||
|
||||
.SH "SYNTAX"
|
||||
.LP
|
||||
pgsql2shp [\fIoptions\fR] \fIdatabase\fR [\fIschema\fR\fB.\fR]\fItable\fR
|
||||
.br
|
||||
pgsql2shp [\fIoptions\fR] \fIdatabase\fR \fIquery\fR
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.LP
|
||||
The pgsql2shp table dumper connects directly to the database and converts a table (possibly created by user query) into a shape file. It is compatible with
|
||||
all versions of PostGIS.
|
||||
The pgsql2shp table dumper connects directly to the database and converts a
|
||||
table (possibly created by user query) into a shape file. It is compatible
|
||||
with all versions of PostGIS.
|
||||
|
||||
Version: 1.1.5 (2006/10/06)
|
||||
|
||||
.SH "USAGE"
|
||||
.LP
|
||||
The <database> is the name of the database to connect to.
|
||||
|
||||
The <table> is the (optionally schema-qualified) table to read spatial
|
||||
data from. Alternatively, you can specify a QUERY whose result will be
|
||||
written into the shapefile.
|
||||
|
||||
.SH "OPTIONS"
|
||||
.LP
|
||||
The commandline options are:
|
||||
|
||||
.TP
|
||||
\fB\-f\fR <\fIfilename\fR>
|
||||
Write the output to a particular filename.
|
||||
|
||||
.TP
|
||||
\fB\-h\fR <\fIhost\fR>
|
||||
The database host to connect to.
|
||||
|
||||
.TP
|
||||
\fB\-p\fR <\fIport\fR>
|
||||
The port to connect to on the database host.
|
||||
|
||||
|
||||
.TP
|
||||
\fB\-P\fR <\fIpassword\fR>
|
||||
The password to use when connecting to the database.
|
||||
|
||||
|
||||
.TP
|
||||
\fB\-u\fR <\fIuser\fR>
|
||||
The username to use when connecting to the database.
|
||||
|
||||
.TP
|
||||
\fB\-g\fR <\fIgeometry column\fR>
|
||||
In the case of tables with multiple geometry columns, the geometry column to use when writing the shape file.
|
||||
|
||||
In the case of tables with multiple geometry columns, the geometry column
|
||||
to use when writing the shape file.
|
||||
.TP
|
||||
\fB\-b\fR
|
||||
Use a binary cursor. When used on pre\-1.0.0 PostGIS versions this will reduce the likelihood of coordinate drift due to conversion to and from WKT format.
|
||||
Coordinate drifts will not occur with PostGIS 1.0.0 and newer versions.
|
||||
It will be slightly faster, but might fail if any NON\-gemetry column lacks
|
||||
a cast to text.
|
||||
|
||||
Use a binary cursor. When used on pre\-1.0.0 PostGIS versions this will
|
||||
reduce the likelihood of coordinate drift due to conversion to and from
|
||||
WKT format. Coordinate drifts will not occur with PostGIS 1.0.0 and newer
|
||||
versions. It will be slightly faster, but might fail if any NON\-gemetry
|
||||
column lacks a cast to text.
|
||||
.TP
|
||||
\fB\-r\fR
|
||||
Raw mode. Do not drop the gid field, or escape column names.
|
||||
|
||||
.TP
|
||||
\fB\-d\fR
|
||||
For backward compatibility: write a 3\-dimensional shape file when dumping from old (pre\-1.0.0) postgis databases (the default is to write a 2\-dimensional shape file in that case). Starting from postgis\-1.0.0+, dimensions are fully encoded.
|
||||
|
||||
For backward compatibility: write a 3\-dimensional shape file when dumping
|
||||
from old (pre\-1.0.0) postgis databases (the default is to write a
|
||||
2\-dimensional shape file in that case). Starting from postgis\-1.0.0+,
|
||||
dimensions are fully encoded.
|
||||
.TP
|
||||
\fB\-k\fR
|
||||
Keep idendifiers case (don't uppercase field names).
|
||||
|
||||
.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 dumper to create shape file from a database might
|
||||
look like this:
|
||||
|
||||
# \fBpgsql2shp -f myfile -p 5555 my_db roads_table\fR
|
||||
|
||||
.SH "AUTHORS"
|
||||
.LP
|
||||
Originally written by Jeff Lounsbury <jeffloun@refractions.net>.
|
||||
Improved and maintained by Sandro Santilli <strk@refractions.net>.
|
||||
Includes small contributions and improvements by others.
|
||||
|
||||
This application uses functionality from shapelib 1.2.9
|
||||
by Frank Warmerdam <warmerda@gdal.velocet.ca> to write to ESRI Shape files.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.LP
|
||||
shp2pgsql(1)
|
||||
|
||||
More information is available at http://postgis.refractions.net
|
||||
|
|
|
@ -2,80 +2,104 @@
|
|||
.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.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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\-s\fR <\fISRID\fR>
|
||||
Creates and populates the geometry tables with the specified SRID.
|
||||
|
||||
.TP
|
||||
\fB\-g\fR <\fIgeometry_column\fR>
|
||||
Specify the name of the geometry column (mostly useful in append mode).
|
||||
|
||||
.TP
|
||||
\fB\-k\fR
|
||||
Keep idendifiers case (column, schema and attributes). Note that attributes in Shapefile are usually all UPPERCASE.
|
||||
|
||||
Keep idendifiers case (column, schema and attributes). Note that attributes
|
||||
in Shapefile are usually all UPPERCASE.
|
||||
.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.
|
||||
|
||||
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
|
||||
Output WKT format, for use with older (0.x) versions of PostGIS.
|
||||
Note that this will introduce coordinate drifts and will drop
|
||||
M values from shapefiles.
|
||||
|
||||
.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).
|
||||
|
||||
.SH "INSTALLATION"
|
||||
.LP
|
||||
Note that -a, -c, -d and -p are mutually exclusive.
|
||||
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:
|
||||
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
|
||||
|
@ -84,13 +108,18 @@ An example session using the loader to create an input file and uploading it mig
|
|||
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@refractions.net>.
|
||||
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.refractions.net
|
||||
|
|
|
@ -574,7 +574,8 @@ as follow:
|
|||
<para>The loader is called <filename>shp2pgsql</filename> and converts
|
||||
ESRI Shape files into SQL suitable for loading in PostGIS/PostgreSQL.
|
||||
The dumper is called <filename>pgsql2shp</filename> and converts PostGIS
|
||||
tables (or queries) into ESRI Shape files.</para>
|
||||
tables (or queries) into ESRI Shape files. For more verbose documentation,
|
||||
see the online help, and the manual pages.</para>
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
||||
|
|
|
@ -1,54 +1,100 @@
|
|||
pgsql2shp - Convert PostGIS Table to Shape
|
||||
~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
VERSION: 0.7 (2002/05/04)
|
||||
|
||||
MORE INFORMATION: http://postgis.refractions.net
|
||||
|
||||
INTRODUCTION:
|
||||
This program takes PostGIS spatial tables and outputs ESRI
|
||||
shape files.
|
||||
|
||||
This application uses functionality from shapelib 1.2.9
|
||||
by Frank Warmerdam <warmerda@gdal.velocet.ca> to write to ESRI
|
||||
Shape files.
|
||||
pgsql2shp(1) PostGIS pgsql2shp(1)
|
||||
|
||||
|
||||
INSTALLATION:
|
||||
|
||||
To build pgsql2shp just run 'make'.
|
||||
Copy the binary wherever you like. :)
|
||||
NAME
|
||||
pgsql2shp - postgis to shapefile dumper
|
||||
|
||||
|
||||
USAGE:
|
||||
|
||||
pgsql2shp [<options>] <database> <table>
|
||||
|
||||
The <database> is the name of the database to connect to.
|
||||
The <table> is the table to read spatial data from.
|
||||
|
||||
Options:
|
||||
-d: set the dump file to be 3 dimensional, the default is 2d only.
|
||||
|
||||
-f <filename>: Use this option to specify the specific name of the
|
||||
file to create. If not specified the file will be named after
|
||||
the table you dumped with shpafile extensions on it.
|
||||
|
||||
-h <host>: allows you to specify what machine the database is on.
|
||||
The default machine if not specifid is the localhost.
|
||||
|
||||
-p <port>: allows you to specify a which database port to connect to.
|
||||
The default if not given is port 5432.
|
||||
|
||||
-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.
|
||||
SYNTAX
|
||||
pgsql2shp [options] database [schema.]table
|
||||
pgsql2shp [options] database query
|
||||
|
||||
|
||||
EXAMPLES:
|
||||
DESCRIPTION
|
||||
The pgsql2shp table dumper connects directly to the database and con-
|
||||
verts a table (possibly created by user query) into a shape file. It is
|
||||
compatible with all versions of PostGIS.
|
||||
|
||||
pgsql2shp -f myfile -p 5555 my_db roads_table
|
||||
Version: 1.1.5 (2006/10/06)
|
||||
|
||||
|
||||
USAGE
|
||||
The <database> is the name of the database to connect to.
|
||||
|
||||
The <table> is the (optionally schema-qualified) table to read spatial
|
||||
data from. Alternatively, you can specify a QUERY whose result will be
|
||||
written into the shapefile.
|
||||
|
||||
|
||||
OPTIONS
|
||||
The commandline options are:
|
||||
|
||||
-f <filename>
|
||||
Write the output to a particular filename.
|
||||
|
||||
-h <host>
|
||||
The database host to connect to.
|
||||
|
||||
-p <port>
|
||||
The port to connect to on the database host.
|
||||
|
||||
-P <password>
|
||||
The password to use when connecting to the database.
|
||||
|
||||
-u <user>
|
||||
The username to use when connecting to the database.
|
||||
|
||||
-g <geometry column>
|
||||
In the case of tables with multiple geometry columns, the geome-
|
||||
try column to use when writing the shape file.
|
||||
|
||||
-b Use a binary cursor. When used on pre-1.0.0 PostGIS versions
|
||||
this will reduce the likelihood of coordinate drift due to con-
|
||||
version to and from WKT format. Coordinate drifts will not occur
|
||||
with PostGIS 1.0.0 and newer versions. It will be slightly
|
||||
faster, but might fail if any NON-gemetry column lacks a cast to
|
||||
text.
|
||||
|
||||
-r Raw mode. Do not drop the gid field, or escape column names.
|
||||
|
||||
-d For backward compatibility: write a 3-dimensional shape file
|
||||
when dumping from old (pre-1.0.0) postgis databases (the default
|
||||
is to write a 2-dimensional shape file in that case). Starting
|
||||
from postgis-1.0.0+, dimensions are fully encoded.
|
||||
|
||||
-k Keep idendifiers case (don't uppercase field names).
|
||||
|
||||
|
||||
INSTALLATION
|
||||
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.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
An example session using the dumper to create shape file from a
|
||||
database might look like this:
|
||||
|
||||
# pgsql2shp -f myfile -p 5555 my_db roads_table
|
||||
|
||||
|
||||
AUTHORS
|
||||
Originally written by Jeff Lounsbury <jeffloun@refractions.net>.
|
||||
Improved and maintained by Sandro Santilli <strk@refractions.net>.
|
||||
Includes small contributions and improvements by others.
|
||||
|
||||
This application uses functionality from shapelib 1.2.9 by Frank
|
||||
Warmerdam <warmerda@gdal.velocet.ca> to write to ESRI Shape files.
|
||||
|
||||
|
||||
SEE ALSO
|
||||
shp2pgsql(1)
|
||||
|
||||
More information is available at http://postgis.refractions.net
|
||||
|
||||
|
||||
|
||||
pgsql2shp(1)
|
||||
|
|
|
@ -1,76 +1,128 @@
|
|||
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.
|
||||
shp2pgsql(1) PostGIS shp2pgsql(1)
|
||||
|
||||
|
||||
INSTALLATION:
|
||||
|
||||
To build shp2pgsql just run 'make'.
|
||||
Copy the binary wherever you like. :)
|
||||
NAME
|
||||
shp2pgsql - shapefile to postgis loader
|
||||
|
||||
|
||||
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)
|
||||
SYNTAX
|
||||
shp2pgsql [options] shapefile [schema.]table
|
||||
|
||||
|
||||
EXAMPLES:
|
||||
DESCRIPTION
|
||||
The shp2pgsql data loader converts ESRI Shape files into SQL suitable
|
||||
for insertion into a PostGIS/PostgreSQL database.
|
||||
|
||||
Loading directly:
|
||||
Version: 1.1.5 (2006/10/06)
|
||||
|
||||
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:
|
||||
USAGE
|
||||
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.
|
||||
|
||||
shp2pgsql -D roads1 roads_table my_db > roads.sql
|
||||
psql -d my_db -f roads.sql
|
||||
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.
|
||||
|
||||
|
||||
OPTIONS
|
||||
The loader has several operating modes distinguished by command line
|
||||
flags:
|
||||
|
||||
(Note that -a, -c, -d and -p are mutually exclusive.)
|
||||
|
||||
-d Drops the database table before creating a new table with the
|
||||
data in the Shape file.
|
||||
|
||||
-a 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.
|
||||
|
||||
-c Creates a new table and populates it from the Shape file. This
|
||||
is the default mode.
|
||||
|
||||
-p Only produces the table creation SQL code, without adding any
|
||||
actual data. This can be used if you need to completely sepa-
|
||||
rate the table creation and data loading steps.
|
||||
|
||||
-D 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.
|
||||
|
||||
-s <SRID>
|
||||
Creates and populates the geometry tables with the specified
|
||||
SRID.
|
||||
|
||||
-g <geometry_column>
|
||||
Specify the name of the geometry column (mostly useful in append
|
||||
mode).
|
||||
|
||||
-k Keep idendifiers case (column, schema and attributes). Note that
|
||||
attributes in Shapefile are usually all UPPERCASE.
|
||||
|
||||
-i Coerce all integers to standard 32-bit integers, do not create
|
||||
64-bit bigints, even if the DBF header signature appears to war-
|
||||
rant it.
|
||||
|
||||
-S 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.
|
||||
|
||||
-w Output WKT format, for use with older (0.x) versions of PostGIS.
|
||||
Note that this will introduce coordinate drifts and will drop M
|
||||
values from shapefiles.
|
||||
|
||||
-W <encoding>
|
||||
Specify the character encoding of Shapefile's attributes. If
|
||||
this option is used the output will be encoded in UTF-8.
|
||||
|
||||
-I Create a GiST index on the geometry column.
|
||||
|
||||
-N <policy>
|
||||
Specify NULL geometries handling policy (insert,skip,abort).
|
||||
|
||||
|
||||
INSTALLATION
|
||||
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.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
An example session using the loader to create an input file and upload-
|
||||
ing it might look like this:
|
||||
|
||||
# shp2pgsql shaperoads roadstable roadsdb > roads.sql
|
||||
# psql -d roadsdb -f roads.sql
|
||||
|
||||
A conversion and upload can be done all in one step using UNIX pipes:
|
||||
|
||||
# shp2pgsql shaperoads roadstable roadsdb | psql -d roadsdb
|
||||
|
||||
|
||||
AUTHORS
|
||||
Originally written by Jeff Lounsbury <jeffloun@refractions.net>.
|
||||
Improved and maintained by Sandro Santilli <strk@refractions.net>.
|
||||
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.
|
||||
|
||||
|
||||
SEE ALSO
|
||||
pgsql2shp(1)
|
||||
|
||||
More information is available at http://postgis.refractions.net
|
||||
|
||||
|
||||
|
||||
shp2pgsql(1)
|
||||
|
|
12
loader/README.txt
Normal file
12
loader/README.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
This directory contains the loader and dumper utility programs.
|
||||
|
||||
The loader can convert shape files to an SQL dump suitable for loading into a PostGIS enabled
|
||||
PostgreSQL database server. The dumper does the opposite, creates a shape file out of an PostGIS
|
||||
table or arbitrary query.
|
||||
|
||||
To compile the program from source, simply run "make" in the source directory. Then copy the
|
||||
binary into your command search path (or wherever you like).
|
||||
|
||||
For usage information, simply run the programs without any arguments, that will display a
|
||||
help screen, and look into the ../doc/man/ directory, there are manpages ready for copying
|
||||
into the manual search path on unixoid systems.
|
|
@ -69,6 +69,7 @@ enum {
|
|||
|
||||
/* globals */
|
||||
int dump_format = 0; /* 0=insert statements, 1 = dump */
|
||||
int simple_geometries = 0; /* 0 = MULTILINESTRING/MULTIPOLYGON, 1 = LINESTRING/POLYGON */
|
||||
int quoteidentifiers = 0;
|
||||
int forceint4 = 0;
|
||||
int createindex = 0;
|
||||
|
@ -739,7 +740,7 @@ usage(char *me, int exitcode)
|
|||
fprintf(stderr, " -s <srid> Set the SRID field. If not specified it defaults to -1.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " (-d|a|c|p) These are mutually exclusive options:\n");
|
||||
fprintf(stderr, " -d Drops the table , then recreates it and populates\n");
|
||||
fprintf(stderr, " -d Drops the table, then recreates it and populates\n");
|
||||
fprintf(stderr, " it with current shape file data.\n");
|
||||
fprintf(stderr, " -a Appends shape file into current table, must be\n");
|
||||
fprintf(stderr, " exactly the same table schema.\n");
|
||||
|
@ -759,6 +760,8 @@ usage(char *me, int exitcode)
|
|||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -I Create a GiST index on the geometry column.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -S Generate simple geometries instead of MULTI geometries.\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -w Use wkt format (for postgis-0.x support - drops M - drifts coordinates).\n");
|
||||
#ifdef USE_ICONV
|
||||
fprintf(stderr, "\n");
|
||||
|
@ -792,9 +795,17 @@ InsertLineString(int id)
|
|||
if (!dump_format) printf("'");
|
||||
if ( sr_id && sr_id != "-1" ) printf("SRID=%s;", sr_id);
|
||||
|
||||
print_wkb_byte(getEndianByte());
|
||||
print_wkb_int(wkbtype);
|
||||
print_wkb_int(obj->nParts);
|
||||
if (simple_geometries==0) // We write MULTI geometries, so generate Header
|
||||
{
|
||||
print_wkb_byte(getEndianByte());
|
||||
print_wkb_int(wkbtype);
|
||||
print_wkb_int(obj->nParts); /* npolys */
|
||||
}
|
||||
else if ((obj->nParts)!=1) // We write Non-MULTI geometries, but have several parts:
|
||||
{
|
||||
fprintf(stderr, "We have a MultiLineString with %d parts, can't use -S switch!\n", obj->nParts);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (pi=0; pi<obj->nParts; pi++)
|
||||
{
|
||||
|
@ -845,6 +856,22 @@ InsertLineStringWKT(int id)
|
|||
|
||||
if (dump_format) printf("SRID=%s;MULTILINESTRING(",sr_id);
|
||||
else printf("GeometryFromText('MULTILINESTRING (");
|
||||
|
||||
if (dump_format) printf("SRID=%s;",sr_id );
|
||||
else printf("GeometryFromText('");
|
||||
|
||||
if (simple_geometries==0) // We write MULTI geometries, so generate Header
|
||||
{
|
||||
printf("MULTILINESTRING(");
|
||||
} else if ((obj->nParts)==1)
|
||||
{
|
||||
printf("POLYGON");
|
||||
}
|
||||
else // We write Non-MULTI geometries, but have several parts:
|
||||
{
|
||||
fprintf(stderr, "We have a Multipolygon with %d parts, can't use -S switch!\n", obj->nParts);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (pi=0; pi<obj->nParts; pi++)
|
||||
{
|
||||
|
@ -874,8 +901,10 @@ InsertLineStringWKT(int id)
|
|||
|
||||
}
|
||||
|
||||
if (dump_format) printf(")\n");
|
||||
else printf(")',%s) );\n",sr_id);
|
||||
if (simple_geometries==0) printf(")");
|
||||
|
||||
if (dump_format) printf("\n");
|
||||
else printf("',%s) );\n",sr_id);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1051,9 +1080,17 @@ InsertPolygon(void)
|
|||
if (!dump_format) printf("'");
|
||||
if ( sr_id && sr_id != "-1" ) printf("SRID=%s;", sr_id);
|
||||
|
||||
print_wkb_byte(getEndianByte());
|
||||
print_wkb_int(wkbtype);
|
||||
print_wkb_int(out_index); /* npolys */
|
||||
if (simple_geometries==0) // We write MULTI geometries, so generate Header
|
||||
{
|
||||
print_wkb_byte(getEndianByte());
|
||||
print_wkb_int(wkbtype);
|
||||
print_wkb_int(out_index); /* npolys */
|
||||
}
|
||||
else if (out_index!=1) // We write Non-MULTI geometries, but have several parts:
|
||||
{
|
||||
fprintf(stderr, "We have a Multipolygon with %d parts, can't use -S switch!\n", out_index);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Write the coordinates */
|
||||
for(pi=0; pi<out_index; pi++)
|
||||
|
@ -1112,8 +1149,22 @@ InsertPolygonWKT(void)
|
|||
|
||||
out_index = FindPolygons(obj, &Outer);
|
||||
|
||||
if (dump_format) printf("SRID=%s;MULTIPOLYGON(",sr_id );
|
||||
else printf("GeometryFromText('MULTIPOLYGON(");
|
||||
if (dump_format) printf("SRID=%s;",sr_id );
|
||||
else printf("GeometryFromText('");
|
||||
|
||||
if (simple_geometries==0) // We write MULTI geometries, so generate Header
|
||||
{
|
||||
printf("MULTIPOLYGON(");
|
||||
}
|
||||
else if (out_index==1)
|
||||
{
|
||||
printf("POLYGON");
|
||||
}
|
||||
else
|
||||
{ // We write Non-MULTI geometries, but have several parts:
|
||||
fprintf(stderr, "We have a Multipolygon with %d parts, can't use -S switch!\n", out_index);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Write the coordinates */
|
||||
for(pi=0; pi<out_index; pi++)
|
||||
|
@ -1149,8 +1200,10 @@ InsertPolygonWKT(void)
|
|||
|
||||
}
|
||||
|
||||
if (dump_format) printf(")\n");
|
||||
else printf(")',%s) );\n",sr_id);
|
||||
if (simple_geometries==0) printf(")");
|
||||
|
||||
if (dump_format) printf("\n");
|
||||
else printf("',%s) );\n",sr_id);
|
||||
|
||||
/* Release all memory */
|
||||
ReleasePolygons(Outer, out_index);
|
||||
|
@ -1228,7 +1281,7 @@ ParseCmdline(int ARGC, char **ARGV)
|
|||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
while ((c = getopt(ARGC, ARGV, "kcdapDs:g:iW:wIN:")) != EOF){
|
||||
while ((c = getopt(ARGC, ARGV, "kcdapDs:Sg:iW:wIN:")) != EOF){
|
||||
switch (c) {
|
||||
case 'c':
|
||||
if (opt == ' ')
|
||||
|
@ -1257,6 +1310,9 @@ ParseCmdline(int ARGC, char **ARGV)
|
|||
case 'D':
|
||||
dump_format =1;
|
||||
break;
|
||||
case 'S':
|
||||
simple_geometries =1;
|
||||
break;
|
||||
case 's':
|
||||
sr_id = optarg;
|
||||
break;
|
||||
|
@ -1311,7 +1367,7 @@ ParseCmdline(int ARGC, char **ARGV)
|
|||
|
||||
if ( opt==' ' ) opt = 'c';
|
||||
|
||||
for (; optind < ARGC; optind++){
|
||||
for (; optind < ARGC; optind++){
|
||||
if(curindex ==0){
|
||||
shp_file = ARGV[optind];
|
||||
}else if(curindex == 1){
|
||||
|
@ -1449,6 +1505,13 @@ SetPgType(void)
|
|||
shpfiletype);
|
||||
break;
|
||||
}
|
||||
|
||||
if (simple_geometries)
|
||||
{
|
||||
// adjust geometry name for CREATE TABLE by skipping MULTI
|
||||
if ((wkbtype & 0x7) == MULTIPOLYGONTYPE) pgtype += 5;
|
||||
if ((wkbtype & 0x7) == MULTILINETYPE) pgtype += 5;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
Loading…
Reference in a new issue