2.postgis导出到shap
虽说有udig可以导出成shap,但是遇到中文乱码也是一件比较令人头痛的事情。
windows下一般都是GBK,最好加着字符集设置。pgsql2shp是不带字符集参数的,那只能求PGCLIENTENCODING参数来起作用了。
export PGCLIENTENCODING=GBK
pgsql2shp osm public.planet_osm_line
关于pgsql2shp的使用说明信息:
RCSID: $Id: pgsql2shp.c 5451 2010-03-22 19:38:40Z pramsey $ RELEASE: 1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
USAGE: pgsql2shp [<options>] <database> [<schema>.]<table>
pgsql2shp [<options>] <database> <query>
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.
3.shap导入到postgis
其实shap到postgis也是比较常用的功能,主要是生成sql文件。
RCSID: $Id: shp2pgsql-core.h 5983 2010-09-19 11:27:05Z mcayland $ RELEASE: 1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
USAGE: shp2pgsql [<options>] <shapefile> [<schema>.]<table>
OPTIONS:
-s <srid> Set the SRID field. Defaults to -1.
(-d|a|c|p) These are mutually exclusive options:
-d Drops the table, then recreates it and populates
it with current shape file data.
-a Appends shape file into current table, must be
exactly the same table schema.
-c Creates a new table and populates it, this is the
default if you do not specify any options.
-p Prepare mode, only creates the table.
-g <geocolumn> Specify the name of the geometry/geography column.
(mostly useful in append mode).
-D Use postgresql dump format (defaults to SQL insert statments).
-G Use geography type (requires lon/lat data).
-k Keep postgresql identifiers case.
-i Use int4 type for all integer dbf fields.
-I Create a spatial index on the geocolumn.
-S Generate simple geometries instead of MULTI geometries.
-w Output WKT format (drops M and introduces coordinate drifts).
-W <encoding> Specify the character encoding of Shape's
attribute column. (default : "WINDOWS-1252").
-N <policy> NULL geometries handling policy (insert*,skip,abort).
-n Only import DBF file.
-? Display this help screen.
一定要注意使用-s -W参数。
