在网上查看的教程中有通过post插件将shp文件导入到postgis数据库中的操作,但是打开自己安装的pgAdmin III并没有psotgis shapefile and dbf插件,只有下面一个插件视图,
所以在网上又找到了一些安装psotgis shapefile and dbf插件的方法,下面是postgis管网上的一个教程,我就是通过这个教程,一步一步安装的。(网站链接:http://www.postgresonline.com/journal/archives/145-PgAdmin-III-Plug-in-Registration-PostGIS-Shapefile-and-DBF-Loader.html)
大体步骤如下:
1.浏览文件选项中的 PG bin 的路径设置是否如图所示
2.将postgisgui 文件夹从C:\Program Files (x86)\PostgreSQL\9.1\bin拷贝到上图中指定的路径下
3.将C:\Program Files (x86)\PostgreSQL\9.1\pgAdmin III\plugins.d\postgis.shp2pgsql-gui.ini文件中的内容拷贝到C:\Program Files (x86)\pgAdmin III\1.18\plugins.d\plugins.ini中,即:如下内容:
;
; PostGIS shp2pgsql-gui (Windows):
;
Title=PostGIS Shapefile and DBF loader
Command="$$PGBINDIR\postgisgui\shp2pgsql-gui.exe" -h "$$HOSTNAME" -p $$PORT -U "$$USERNAME" -d "$$DATABASE" -W "$$PASSWORD"
Description=Open a PostGIS ESRI Shapefile or Plain dbf loader console to the current database.
KeyFile=$$PGBINDIR\postgisgui\shp2pgsql-gui.exe
Platform=windows
ServerType=postgresql
Database=Yes
SetPassword=Yes
重启pgAdmin即可
在导入shp文件的时候同样也遇到了写问题:点击Import时提示如下错误:
dbf file (.dbf) can not be opened.
网上有教程说:1.shp文件的路径太深;2.shp文件路径中存在中文。
当上面两个条件都满足时,还是报以同样的错误,最后在GeoServer的工作空间下找到了一个shp文件,发现同名的还有其他的bdf,prj的文件存在,索性吧所有的文件考到同一个目录下,在Import竟然成功了。现在还么有搞明白具体是怎么个原理,后面研究