line导入postgis数据库
1、创建新的数据库a
su postgres
psql -p 5432
create database a with owner dbuser(新建数据库a)
Crtl+z回退
psql -U dbuser -d a
CREATE EXTENSION postgis
CREATE EXTENSION postgis_topology
CREATE EXTENSION pgrouting
2、QGIS绑定数据库a
修改导入文件:
<!DOCTYPE connections>
<qgsPgConnections version=”1.0″>
<postgis port=”5432″ saveUsername=”true” password=”dbuser” savePassword=”true” sslmode=”1″ service=”” username=”dbuser” host=”host名” database=”a” name=”a” estimatedMetadata=”false”/>
</qgsPgConnections>
导入到QGIS
3、line导入数据库a
模式:public 表格:tbl_path 主键:id
ALTER TABLE tbl_path ADD COLUMN “source” integer;
ALTER TABLE tbl_path ADD COLUMN “target” integer;
SELECT pgr_createTopology(‘tbl_path’, 0.000002, ‘geom’, ‘gid’);
ALTER TABLE tbl_path ADD COLUMN “length” float8;
UPDATE tbl_path set length=ST_Length(geom);
转载自:https://blog.csdn.net/xiaoyanninan/article/details/47086761