• 系统性整理项目:第一篇(续篇)-osm存入PostgreSQL+PostGIS并构建路网表结构


    一、PostgreSQL 10+ PostGIS 3已经安装完成

    二、OSM(beijing-latest.osm)文件已经成功转换成EPSG:2436平面坐标系,并且已经完成在交点处分割道路,最后保存成OSM格式(也可以是shp格式)

    三、利用osmosis将.osm文件存入PostgreSQL+PostGIS中,步骤如下:

    1. 新建db-epm数据库,并新建扩展:hstore、postgis和pgrouting,可以用用DBeaver来新建扩展,也可通过命令来实现:

       create extension hstore;

       create extension postgis;

       create extension pgrouting;

    2. 打开cmd

    3. C:Usersjiangshan>cd C:Program Files (x86)osmosisin

    4. C:Program Files (x86)osmosisin>psql -h localhost -p 5432 -U postgres -d db-epm -f ../script/pgsnapshot_schema_0.6.sql

       用户 postgres 的口令:*****

    5. 用DBeaver来查看db-epm数据库,此时就会多了几个表,如下:

     

     接下来,构建网络

    6. C:Program Files (x86)osmosisin>osmosis --read-xml D:/EngineeringProjectManagement/beijing-latest-cars.osm --write-pgsql host="localhost" database=“db-epm" user="postgres" password="jiangshan"

    成功后,db-epm数据库中,就有数据了,如下:

     

     7. 切换至xml文本文件beijing.osm所在目录(cd D:EngineeringProjectManagementconverted.shp-2436-seg)

       >osm2pgrouting --file D:/EngineeringProjectManagement/converted.shp-2436-se/Beijing-2436.osm --conf S:/PostgreSQL/10/bin/mapconfig_for_cars.xml --schema public --addnodes --prefix bj_ --suffix _car --clean -d db-epm -U postgres -h localhost -p 5432 -W jiangshan

    或者 采用以下带全部参数

       >osm2pgrouting --file D:/EngineeringProjectManagement/converted.shp-2436-seg/beijing-2436.osm --conf S:/PostgreSQL/10/bin/mapconfig_for_cars.xml --schema public --prefix bj_ --suffix _car --addnodes --attributes --tags --clean -d db-epm -U postgres -h localhost -p 5432 -W jiangshan

    正常应该输出以下:

       Creating tables...

       TABLE: public.bj_ways_car created ... OK.

       TABLE: public.bj_ways_car_vertices_pgr ... OK.

       TABLE: public.bj_pointsofinterest_car created ... OK.

       TABLE: public.configuration created ... OK.

       TABLE: public.osm_nodes created ... OK.

       TABLE: public.osm_ways created ... OK.

       TABLE: public.osm_relations created ... OK.

       Opening configuration file: S:/PostgreSQL/10/bin/mapconfig_for_cars.xml

       ………………………………………..

       Elapsed time: 285.297 Seconds.

       User CPU time: -> 285.299 seconds

       #########################

    8. 用DBeaver来查看新建的表及导入的路网数据(表名称可能不一样,在实际中请注意表名称统一)

       public.bj_ways_car

       public.bj_ways_car_vertices_pgr

       public.bj_pointsofinterest_car

       public.configuration

       public.osm_nodes

       public.osm_ways

       public.osm_relations

    个人学习记录
  • 相关阅读:
    Linux随笔 DNS搭建
    总算亲自看见了一个网站被黑后的页面。
    [转]XP如何禁止媒体文件预览
    用Word2007发Blog的配置方法(多图)。
    C#通过http访问olap
    测试Word2007
    用IronPython作为.Net的脚本语言。
    用批处理写的显示磁盘剩余空间的小程序。
    事开机时Num Lock键打开。
    快捷方便的对js文件进行语法检查。
  • 原文地址:https://www.cnblogs.com/jeshy/p/15137330.html
Copyright © 2020-2023  润新知