CentOS7下开源osm格式地图数据的导入与展示

3 篇文章 0 订阅
2 篇文章 0 订阅

OSM数据有几种下载方式:1)直接通过wget下载; 2)通过官网直接导出指定区域; 3)通过osm2pgsql导入postgis; 4)geoserver或其他地图服务发布

1.通过wget下载数据

进入http://download.geofabrik.de/, 可以按照自己的需求下载不同国家不同区域的数据。本文提供了一下几个例子

全球数据下载:

wget -c http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf

中国数据下载:

wget -c http://download.geofabrik.de/asia/china-latest.osm.pbf

2.通过官网直接导出指定区域数据

进入https://www.openstreetmap.org 点击导出,拖动地图就可以按照范围导出自己想要的范围

 

3.通过osm2pgsql导入postgis

CentOS7安装osm2pgsql ,Git下载osm2pgsql.zip压缩包,完成后 osm2pgsql -v 出现版本号,说明成功安装。

cd osm2pgsql
 
cmake ..
 
make 
 
sudo make install

在postgis数据库中建好名为osm库,并且执行将库设置为postgis空间库的操作。

CREATE EXTENSION postgis;

进入下载好的osm文件夹,按照如下方式,-u:数据库用户名 -p:端口,-h:地址,-d:导入到的数据库名,最后一项,为需要导入的文件地址与名称。

osm2pgsql -U postgres -H 127.0.0.1 -P 5432 -d osm map.osm

导入完成后如下显示,表示已经导入到postgis的osm库中

Database version: 9.4.15
Allocating memory for dense node cache
Allocating dense node cache in one big chunk
Allocating memory for sparse node cache
Sharing dense sparse
Node-cache: cache=800MB, maxblocks=12800*65536, allocation method=3
Using projection SRS 3857 (Spherical Mercator)
Using built-in tag processing pipeline
Setting up table: planet_osm_point
Setting up table: planet_osm_line
Setting up table: planet_osm_polygon
Setting up table: planet_osm_roads

Reading in file: map.osm
Using XML parser.
Processing: Node(14k 14.0k/s) Way(2k 2.00k/s) Relation(388 388.0/s)  parse t
Node stats: total(14336), max(8050788257) in 0s
Way stats: total(2284), max(860113624) in 0s
Relation stats: total(388), max(11643624) in 0s
node cache: stored: 14336(100.00%), storage efficiency: 38.90% (dense blockse: 100.00%
Sorting data and creating indexes for planet_osm_line
Sorting data and creating indexes for planet_osm_polygon
Sorting data and creating indexes for planet_osm_point
Sorting data and creating indexes for planet_osm_roads
Using native order for clustering
Using native order for clustering
Using native order for clustering
Using native order for clustering
Copying planet_osm_roads to cluster by geometry finished
Creating geometry index on planet_osm_roads
Creating indexes on planet_osm_roads finished
All indexes on planet_osm_roads created in 0s
Completed planet_osm_roads
Copying planet_osm_point to cluster by geometry finished
Creating geometry index on planet_osm_point
Creating indexes on planet_osm_point finished
All indexes on planet_osm_point created in 0s
Completed planet_osm_point
Copying planet_osm_polygon to cluster by geometry finished
Creating geometry index on planet_osm_polygon
Creating indexes on planet_osm_polygon finished
Copying planet_osm_line to cluster by geometry finished
Creating geometry index on planet_osm_line
Creating indexes on planet_osm_line finished
All indexes on planet_osm_polygon created in 0s
Completed planet_osm_polygon
All indexes on planet_osm_line created in 0s
Completed planet_osm_line

Osm2pgsql took 1s overall

4.postgis发布geoserver图层

自信点你知道的

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

捣net菜菜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值