在Ubuntu16.04系统上搭建OSM 瓦片服务器

本文档详细介绍了如何在Ubuntu 16.04系统上搭建OpenStreetMap(OSM)瓦片服务器。步骤包括更新系统、安装PostGIS与PostgreSQL数据库、下载地图数据、导入数据到数据库、安装mod_tile、生成Mapnik样式表、配置渲染及Apache Web服务器,最后展示了使用OpenLayer和Leaflet库显示瓦片地图的方法。
摘要由CSDN通过智能技术生成

<!本贴参照互联网上网友的帖子,加入自己实际操作过程中遇到问题的解决方法;仅供学习交流用途。>

Step 1: 更新Ubuntu的软件库

    # sudo apt update

    # sudo apt upgrade

 

Step 2: 使用PostGIS安装PostgreSQL数据库服务器

We will usePostgreSQL to store map data. PostGIS is a geospatial extenstion to PostgreSQL.Run the following commands to install them.

# sudo apt install postgresql postgresql-contrib postgis postgresql-9.5-postgis-2.2

 

A usernamed postgres will be created during the installation process. Thisallows the use of peer authentication. Let’s switch tothe postgres user:

# sudo -u postgres -i

 

Create a PostgreSQL database user osm

    # createuser osm

 

Create adatabase named gis andat the same time make osm as the owner of the database. -EUTF8 specifies the character encoding scheme to be used in the database isUTF8.

# createdb -E UTF8 -O osm gis

 

Create hstore and postgis extension.

# psql -c "CREATE EXTENSION hstore;" -d gis
# psql -c "CREATE EXTENSION postgis;" -d gis

 

Exit from the postgres user.

# exit

 

Create osmuseruser on your operating system so the tile server can run as osmuser user.

# sudo adduser osmuser

 

 

Step 3: 下载地图样式表和地图数据

First switch to osmuser user

  # su - osmuser

 

Download the latest CartoCSS mapstylesheets to the osmuser user’s homedirectory.

  # wget https://github.com/gravitystorm/openstreetmap-carto/archive/v2.41.0.tar.gz

 

Extract it.

  # tar xvf v2.41.0.tar.gz

 

Next, download map data to the osmuser user’s home directory. Use the belowcommand to download the map data of the whole planet (32G).

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

【If you want a map of individual country orstate, go to http://download.geofabrik.de.Also, BBBike.org provides extractsof more than 200 cities and regions world-wide in different formats.】

 

For example, download the map data of GreatBritain (847M).

# wget -c http://download.geofabrik.de/europe/great-britain-latest.osm.pbf

 

Now exit from the osmuser user.

       #exit

 

Step 4: 将地图数据导入PostgreSQL

To import mapdata, we need to install osm2pgsql which converts OpenStreetMap datato postGIS-enabled PostgreSQL databases.

  # sudo apt install osm2pgsql

 

Switch to osmuseruser again.

       #su - osm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值