怎么将shp导入postgis 如何用qgis将shp图层导入postgres sql 数据...

\u5982\u4f55\u4f7f\u7528shp2pgsql \u5c06shp\u683c\u5f0f\u7684GIS\u6570\u636e\u5bfc\u5165\u5230PostgreSQL

\u4f7f\u7528postgreSQL\u63d0\u4f9b\u7684shp2pgsql.exe\u529f\u80fd\u53ef\u4ee5\u5c06.shp\u683c\u5f0f\u7684\u5730\u7406\u6570\u636e\u8f6c\u6362\u6210sql\u8bed\u53e5\u3002
shp2pgsql.exe\u5de5\u5177\u5728postgreSQL\u7684\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684bin\u76ee\u5f55\u4e2d(\u524d\u63d0\u662f\u5b89\u88c5postgreSQL\u7684\u65f6\u5019\u9009\u62e9\u4e86\u5bf9postgis\u7684\u652f\u6301\uff09
\u4f7f\u7528\u65b9\u6cd5\uff1a
E:\development_tools\postgres-8.4\bin>shp2pgsql -s 4326 F:\tmp\res1_4m.shp citi
y>f:\city.sql
Shapefile type: Point
Postgis type: POINT[2]
\u4f8b\u5b50\u4e2d\u7528\u7684\u6570\u636e\u662f\u9996\u90fd\u548c\u7701\u7ea7\u884c\u653f\u4e2d\u5fc3\u7684\u6570\u636e\uff0c\u6240\u4ee5\u662f\u201c\u70b9\u201d\u7c7b\u578b\uff0c
*\u8f6c\u6362\u7684\u65f6\u5019\u9700\u8981\u6307\u5b9a\u4fdd\u5b58\u7684\u5b8c\u6574\u8def\u5f84\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002

\u4f7f\u7528postgreSQL\u63d0\u4f9b\u7684shp2pgsql.exe\u529f\u80fd\u53ef\u4ee5\u5c06.shp\u683c\u5f0f\u7684\u5730\u7406\u6570\u636e\u8f6c\u6362\u6210sql\u8bed\u53e5\u3002
shp2pgsql.exe\u5de5\u5177\u5728postgreSQL\u7684\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684bin\u76ee\u5f55\u4e2d(\u524d\u63d0\u662f\u5b89\u88c5postgreSQL\u7684\u65f6\u5019\u9009\u62e9\u4e86\u5bf9postgis\u7684\u652f\u6301\uff09
\u4f7f\u7528\u65b9\u6cd5\uff1a
E:\development_tools\postgres-8.4\bin>shp2pgsql -s 4326 F:\tmp\res1_4m.shp citi
y>f:\city.sql
Shapefile type: Point
Postgis type: POINT[2]
\u4f8b\u5b50\u4e2d\u7528\u7684\u6570\u636e\u662f\u9996\u90fd\u548c\u7701\u7ea7\u884c\u653f\u4e2d\u5fc3\u7684\u6570\u636e\uff0c\u6240\u4ee5\u662f\u201c\u70b9\u201d\u7c7b\u578b\uff0c
*\u8f6c\u6362\u7684\u65f6\u5019\u9700\u8981\u6307\u5b9a\u4fdd\u5b58\u7684\u5b8c\u6574\u8def\u5f84\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002

Shapfile文件为ESRI公司的文件存储格式,并且得到了业界广
泛的支持。Shapfile格式是一种简单的,用非拓朴关系的形式存储几何位置和地理特征的属性信息的格式。虽然GeoServer采用Shapfile
文件可以快速的创建网上地图服务,但它的缺点确很明显:

  1、Shapefile只支持一个图层,在实际中没有意义。

  2、直接保用SHP文件不安全,Shapfile文件很容易被病毒或其他原因误删除。

  3、GeoServer中用Shapfile文件作数据源的效率是很低的。

  4、Shapfile中的汉字GeoServer不能解析,会出现乱码。

  5、数据库可以方便的对地理信息进行查询。

用PostGIS管理空间数据

  PostGIS支持GIST空间索引(附录1)、规范窗体,能很大的提高处理效率。

  
OGC格式只提供二维的几何体,且相关联的SRID从未深入的用于输入输出请求,PostGIS支持OpenGIS组织"Simple Features
for SQL"规范指定的所有GIS对象和函数,并进行了扩展,格式是EWKB、EWKT,其中增加了对3DZ,3DM和4D
坐标系的支持(当然三维、四维数据的OGC标准还未完全制定),深入引进了SRID信息。

  空间数据表结构:PostGIS中存在两个必需的元数据表格, SPATIAL_REF_SYS(空间参考表格) 和 GEOMETRY_COLUMNS(几何体属性列),两个表用于存储空间数据库使用的坐标系统数字ID和文本描述。

  PostGIS的shp2pgsql命令可以将Shapfile直接导入到数据库中也可以导出为SQL文件,推荐先导出为SQL文件再将此文件在SQL运行窗口中执行可将数据导入数据库。代码如下:

Shapfile到SQL语句:

  shp2pgsql 路径/shp数据文件名 新建的数据表名 > 路径/SQL文件名.sql

Shapfile直接入库:

  shp2pgsql -c 路径/shp数据文件名 新建的数据表名 数据库名|psql -d 数据库名

举例说明:

  如将一Shapfile文件“c:/road.shp”导入到数据表“road”中,数据库为“sjzmap”。

  1、运行“命令提示符”。

  2、切换至PostgreSQL数据库安装目录中的bin目录下。

  3、执行此目录下的shp2pgsql命令:“shp2pgsql c:/road.shp road > c:/road.sql”。

  4、如将此文件直接导入数据库(不推荐):“shp2pgsql -c c:/road.shp road sjzmap | psql -d sjzmap”。

5、使用pgAdmin3 选择数据库,再导入表。

注:

-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 separate 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.

-k

Keep identifiers' case (column, schema and attributes). Note that attributes in Shapefile are 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 warrant it.

-I

Create a GiST index on the geometry column.

-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 encoding of the input data (dbf file). When used, all
attributes of the dbf are converted from the specified encoding to UTF8.
The resulting SQL output will contain a SET CLIENT_ENCODING to UTF8
command, so that the backend will be able to reconvert from UTF8 to
whatever encoding the database is configured to use internally.

  • 鎬庝箞鎺堜簣鏅氱敤鎴锋潈闄恈reate extension "postgis
    绛旓細1銆丼hapefile鍙敮鎸佷竴涓浘灞傦紝鍦ㄥ疄闄呬腑娌℃湁鎰忎箟銆2銆佺洿鎺ヤ繚鐢SHP鏂囦欢涓嶅畨鍏紝Shapfile鏂囦欢寰堝鏄撹鐥呮瘨鎴栧叾浠栧師鍥犺鍒犻櫎銆3銆丟eoServer涓敤Shapfile鏂囦欢浣滄暟鎹簮鐨勬晥鐜囨槸寰堜綆鐨勩4銆丼hapfile涓殑姹夊瓧GeoServer涓嶈兘瑙f瀽锛屼細鍑虹幇涔辩爜銆5銆佹暟鎹簱鍙互鏂逛究鐨勫鍦扮悊淇℃伅杩涜鏌ヨ銆傜敤PostGIS绠$悊绌洪棿鏁版嵁 PostGIS鏀寔...
  • POSTGIS鐨勭増鏈湁鍝簺?
    绛旓細V1.1.4銆PostGIS V1.1.4涓昏鏀硅繘鐨勫湴鏂瑰寘鎷:鈶存彁渚涗簡瀵逛簬灏嗚鍙戝竷鐨凱ostgreSQL V8.2鐨勬敮鎸侊紱鈶典慨澶嶄簡鍑芥暟collect涓瓨鍦ㄧ殑bug锛涒懚鍦∕akeBox2d鍜孧akeBox3d涓鍔犱簡瀵筍RID鐨勫尮閰嶆鏌ワ紱鈶锋彁楂樹簡pgsql2shp鐨勮繍琛屽苟鍙戞э紱鈶歌繘涓姝ユ敼杩涗簡瀵逛簬Java鐨勬敮鎸併傚弬鑰冭祫鏂欙細http://baike.baidu.com/view/1871110...
  • 濡備綍鍚屾postgresql鏁版嵁
    绛旓細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 sh apefiles.Specify encoding of the input data (dbf file). When used, all attributes of the dbf are converted from the specified ...
  • Geoserver鎬庝箞璁块棶shapefile鎴PostGIS鏁版嵁搴
    绛旓細鍦ㄦ坊鍔爌ostgis鏁版嵁鍒癵eoserver涔嬪墠锛屾偍闇瑕佸皢鏁版嵁瀵煎叆鍒皃ostgis鏁版嵁搴撲腑锛濡備綍灏shapefile鏁版嵁瀵煎叆postgis鏁版嵁搴擄紵鎿嶄綔濡備笅锛氣憼 鐢熸垚sql鑴氭湰銆備娇鐢shp2pgsql绋嬪簭鐢熸垚shp鏂囦欢瀵瑰簲鐨剆ql鑴氭湰銆傚亣瀹歅ostgreSQL瀹夎璺緞涓洪粯璁わ紝閭d箞鍗曞嚮windows寮濮嬭彍鍗曘佽繍琛屻佽緭鍏md銆佸洖杞︺傝緭鍏ュ懡浠よ"C:\Program Files\PostgreSQL...
  • postgresql 鍜postgis鍖哄埆鏄粈涔?
    绛旓細璇锋煡鐪嬪叾鎵嬪唽浜嗚В濡備綍璁剧疆銆傝繖閲岀缉鏀惧埌鍔犳嬁澶т竴澶勮憲鍚嶇殑婀栨硦缇ゃ 鑷姩鍒涘缓绌洪棿鏁版嵁琛ㄥ崟 OSGeo Live 鐨勫鏁版闈 GIS 绯荤粺閮藉彲浠灏 shp 绛夋枃浠瀵煎叆鏁版嵁搴撱傝繖閲屼緷鐒朵娇鐢 QGIS 婕旂ず銆 QGIS 涓鍏 shp 鍙互浣跨敤 PostGIS Manager 鎻掍欢銆傚湪 Plugins 鑿滃崟閫夋嫨 FetchPlugins 瀵煎叆鏈鏂扮殑瀹樻柟鎻掍欢鍒楄〃(闇瑕佺綉缁滆繛鎺)銆傛壘鍒 ...
  • 濡備綍瀵煎叆PostgreSQL鏁版嵁搴撴暟鎹
    绛旓細$ shp2pgsql china china_postgis > tmp.sql$ psql -d wen2 -f roads.sql杩欎釜宸ュ叿寰堝ソ鐢,缂虹偣鍦ㄤ簬浣跨敤鑼冨洿鏈夐檺,鍙拡瀵筍hape鏂囦欢鏍煎紡銆3.2.2 ogr2ogrPostGIS鏈韩鐨剆hp2pg宸ュ叿鍙妸shape鏂囦欢杞崲鍒癙ostGIS 鏁版嵁搴撲腑,閭濡備綍鎶鍏朵粬鐨凣IS鏁版嵁鍔犲叆鍛?姣斿璇碝apInfo鐨刴id鏍煎紡,ESRI鐨別00鏍煎紡鍛?杩欏氨瑕佷娇鐢╫gr杩欎釜宸ュ叿...
  • 鎬庝箞涓婁紶microarray鏁版嵁鍒癵eo鏁版嵁搴
    绛旓細鍦ㄦ坊鍔爌ostgis鏁版嵁鍒癵eoserver涔嬪墠锛屾偍闇瑕佸皢鏁版嵁瀵煎叆鍒皃ostgis鏁版嵁搴撲腑锛濡備綍灏shapefile鏁版嵁瀵煎叆postgis鏁版嵁搴擄紵鎿嶄綔濡備笅锛氣憼 鐢熸垚sql鑴氭湰銆備娇鐢shp2pgsql绋嬪簭鐢熸垚shp鏂囦欢瀵瑰簲鐨剆ql鑴氭湰銆傚亣瀹歅ostgreSQL瀹夎璺緞涓洪粯璁わ紝閭d箞鍗曞嚮windows寮濮嬭彍鍗曘佽繍琛屻佽緭鍏md銆佸洖杞︺傝緭鍏ュ懡浠よ"C:\Program Files\PostgreSQL...
  • 扩展阅读:打开shp导入mdb输出要素 ... ovobj怎么转换成shp ... 安卓手机ssh工具 ... psd导入ai图层怎么分开 ... arcgis将shp导入mdb ... pe下怎么安装img镜像 ... shp导入gdb为空 ... 怎么把shp导入mdb ... arcmap如何把shp转换成mdb ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网