手机版
你好,游客 登录 注册
背景:
阅读新闻

PostGIS常见的空间数据的导入导出

[日期:2012-08-09] 来源:Linux社区  作者:cnhome [字体:大 中 小]

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参数。

linux
相关资讯       PostGIS 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款