在PostgreSQL中建立GIS数据库
postgres=# create user gisuser password '123456';
CREATE ROLE
postgres=# create tablespace tbs_geo owner gisuser location '/tbs_postgisdb';
CREATE TABLESPACE
postgres=# create database postgisdb owner=gisuser tablespace=tbs_geo;
CREATE DATABASE
postgres=# \c postgisdb postgres
You are now connected to database "postgisdb" as user "postgres".
postgisdb=# \i /postgresql/share/contrib/postgis-2.1/postgis.sql
SET
BEGIN
CREATE FUNCTION
.
.
.
GRANT
COMMIT
postgisdb=# \i /postgresql/share/contrib/postgis-2.1/spatial_ref_sys.sql
BEGIN
INSERT 0 1
.
.
.
INSERT 0 1
COMMIT
ANALYZE
postgisdb=# \q
#
测试导入shp文件
(首先由shp生成pgsql语句)
# shp2pgsql -W 'GBK' /postgresql/testdata/testshp target_table_name > /posgresql/target_sqlfile.sql
Shapefile type: Point
Postgis type: POINT[2]
# psql -d postgisdb -U gisuser -f /postgresql/target_sqlfile.sql
SET
SET
BEGIN
CREATE TABLE
ALTER TABLE
addgeometrycolumn
---------------------------------------------------------
public.target_table_name.geom SRID:0 TYPE:POINT DIMS:2
(1 row)
INSERT 0 1
INSERT 0 1
(然后运行此pgsql语句生成target_table_name表)
# psql -d postgisdb -U gisuser -f /postgresql/target_sqlfile.sql
shp2pgsql -W 'GBK' /postgresql/testdata/testshp target_table_name > /postgresql/targ
get_sqlfile.sqlpsql -d postgisdb -U gisuser -f /postgresql/target_sqlfile.sql
在pgAdmin中查看此表的内容,若有,则导入正常。
阅读(4262) | 评论(0) | 转发(0) |