OSM(Open Street Map)

OSM(Open Street Map)

OpenStreetMap (OSM)

It is a collaborative project to create a free editable map of the world.

Now ,before beginning to make your own tile server, let me explain you some termonologies.

Web browser

Data provided by the OpenStreetMap project can be viewed in a web browser with JavaScript support via Hypertext Transfer Protocol (HTTP) on its official website.


OsmAnd is free software for Android and iOS mobile devices that can use offline vector data from OSM. It also supports layering OSM vector data with prerendered raster map tiles from OpenStreetMap and other sources.


It is a wonderful example of what you can do with the tools and data of OpenStreetMap catalyzed by an idea.

Tiled web map/ slippy map/ raster tile map

It is a map displayed in a browser by seamlessly joining dozens of individually requested image files over the internet.

It is currently the most popular way to display and navigate maps, replacing other methods such as WMS which typically display a single large image, with arrow buttons to navigate to nearby areas.

Google Maps was one of the first major mapping sites to use this technique. Tiled web maps may in turn be replaced by vector tiles as the standard.

Benifit of Having your own tile server

Maybe you need to have access to you map even when your internet provider is down. Or when the power is off. Or both. It won’t take much for you to see the benefit of having your own piece of OpenStreetMap infrastructure

Now it’s turn to install, setup and configure all the necessary software to operate your own tile server.

These instructions build what OpenStreetMap calls a tile server. That is, a computer that uses the OSM data set to create map images that are suitable for a web site. Not every OpenStreetMap function is supported, but you will be able to create a local map, keep it up to date and customize it for your own purposes.

Software installation

The OSM tile server stack is a collection of programs and libraries that work together to create a tile server. As so often with OpenStreetMap, there are many ways to achieve this goal and nearly all of the components have alternatives that have various specific advantages and disadvantages. This tutorial describes the most standard version that is also used on the main OpenStreetMap.org tile server.

It consists of 5 main components: Mod_tile, renderd, mapnik, osm2pgsql and a postgresql/postgis database. Mod_tile is an apache module, that serves cached tiles and decides which tiles need re-rendering – either because they are not yet cached or because they are outdated. Renderd provides a priority queueing system for rendering requests to manage and smooth out the load from rendering requests. Mapnik is the software library that does the actual rendering and is used by renderd.

In order to build these components, a variety of dependencies need to be installed first:

I am installing this OSM on Ubuntu 15.10.

If you are installing it on Ubuntu 14.04, then you have to edit the below command  little bit.

Write “libtiff4” in place of “libtiff5”.


sudo apt-get install libboost-all-dev subversion git-core tar unzip wget bzip2 build-essential autoconf libtool libxml2-dev libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev munin-node munin libprotobuf-c0-dev protobuf-c-compiler libfreetype6-dev libpng12-dev libtiff5-dev libicu-dev libgdal-dev libcairo-dev libcairomm-1.0-dev apache2 apache2-dev libagg-dev liblua5.2-dev ttf-unifont lua5.1 liblua5.1-dev libgeotiff-epsg node-carto

Without running the above command you can not install postgresql.

Installing postgresql / postgis

PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing location queries to be run in SQL.

Most spatial databases allow representing simple geometric objects such as points, lines and polygons. Some spatial databases handle more complex structures such as 3D objects, topological coverages, linear networks, and TINs.

On Ubuntu there are pre-packaged versions of both postgis and postgresql, so these can simply be installed via the Ubuntu package manager.


sudo apt-get install postgresql postgresql-contrib postgis postgresql-9.4 -postgis-2.1

Now you need to create a postgis database. The defaults of various programs assume the database is called gis and we will use the same convention in this tutorial, although this is not necessary. Substitute your username for username in the two places below. This should be the username that will render maps with Mapnik.

The default superuser for PostgreSQL is called postgres. You may need to login as this user first.

sudo -u postgres -i

Now, you will get username postgres@yourpcname

createuser username

createdb -E UTF8 -O username gis


Create a Unix user for this user, too, choosing a password when prompted:

sudo useradd -m username
sudo passwd username

Set up PostGIS on the PostgreSQL database (again, substitute your username for username below):

sudo -u postgres psql
\c gis
ALTER TABLE geometry_columns OWNER TO username;
ALTER TABLE spatial_ref_sys OWNER TO username;

Installing osm2pgsql

osm2pgsql is under active development and is best compiled from source.

osm2pgsql is a command-line based program that converts OpenStreetMap data to postGIS-enabled PostgreSQL databases.

mkdir ~/src
cd ~/src
git clone git://github.com/openstreetmap/osm2pgsql.git
cd osm2pgsql


sudo apt-get install make cmake g++ libboost-dev libboost-system-dev \
  libboost-filesystem-dev libexpat1-dev zlib1g-dev \
  libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev lua5.2 \


mkdir build && cd build
cmake ..
sudo make install


Congratulations, you have installed osm2pgsql. Now in my next blog I will explain how to install Mapnik library.






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s