How to make your own maps/tiles

This wiki here describes how to render osm based vector planet.osm files to raster images. Please note we will use china.osm (which is a cut down version of planet.osm) for this wiki, as planet.osm is too huge for everything to be done in a timely manner.

Mapnik on Ubuntu

on ubuntu 12.04 do:

sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:mapnik/v2.0.2
sudo apt-get update && sudo apt-get -y install libmapnik mapnik-utils python-mapnik

Postgis Installation Guide

http://wiki.openstreetmap.org/wiki/Mapnik/PostGIS

on ubuntu 12.04 do: (add c2h2 as the user and china as the database)

sudo apt-get install -y postgresql-9.1-postgis postgresql-contrib-9.1
sudo -u postgres -i -H
createuser -SdR c2h2
createdb -E UTF8 -O c2h2 china
psql -d china -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
psql -d china -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql

psql china -c "ALTER TABLE geometry_columns OWNER TO c2h2"
psql china -c "ALTER TABLE spatial_ref_sys OWNER TO c2h2"
exit  

edit postgres ACL: (change md5 -> trust for local)

sudo vim /etc/postgresql/9.1/main/pg_hba.conf 
sudo /etc/init.d/postgresql restart 

Install osm2pgsql (the osm -> postgis converting tool)

Strongly recommand to install by using this ppa repo:

sudo add-apt-repository -y ppa:kakrueger/openstreetmap
sudo apt-get update && sudo apt-get install -y osm2pgsql

native apt-get is doable but might have some problems + bugs: (not suggested using below)

fix osm2pgsql bug: (according to: http://lists.openstreetmap.org/pipermail/dev/2011-June/022995.html)

sudo  cp /usr/share/osm2pgsql/default.style /usr/share/

Load maps into postgis

on ubuntu 12.04 do: (note this gonna dl 70mb~ file and take approx 10min to import into postgis)

wget http://download.geofabrik.de/osm/asia/china.osm.pbf && osm2pgsql -d china -U c2h2 --slim -C 2000 china.osm.pbf

Render our tiles with mapnik + python

Now we generate our tiles with 4 theads:

Clone our git: (copied from http://svn.openstreetmap.org/applications/rendering/mapnik/)

git clone git@piza.cc:ntmaps.git
cd ntmaps/mapnik-render
./get-coastlines-192.168.8.25.sh
python generate_xml.py osm.xml c2h2_china.xml  --password '' --host 'localhost' --user 'c2h2' --dbname 'china' --port '5432'
python gen_china_multi.py c2h2_china.xml

wait .... and done!

Other rendering map/tiles

Tile Server Guide (this is AIO package, and not very well tested by author of this wiki)

You will want this if you are building a tile server in one go.

http://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/

Tilestache Guide

https://github.com/migurski/TileStache

guide to install deps: http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/

git clone https://github.com/migurski/TileStache.git
sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev python2.7-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
sudo pip install -U PIL modestmaps simplejson werkzeug
cd TileStashe
python scripts/tilestache-server.py

If you still have problem with PIL

wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
cd Imaging-1.1.7 && python setup.py

Other Map Sources (cut down versions)

Good Reading Sources + Refs

Other Postgress FAQ

TO-READ

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值