About the Author

Sajjad is a Bangalore based cartographer and programmer, building tools to scale the data team and analyze large spatial data-sets at Mapbox. He has been working closely with OpenStreetMap data and technology for over 6 years.

OpenStreetMap and GIS: Bridging the gap.

Many a times I have heard my GIS friends say that OpenStreetMaps are ‘just’ street maps and lack quality and ability to be used in efficient GIS applications. But this is not always true. I would like to make a comment that, GIS applications they mention still uses any kind of map data which are essentially gathered and processed through GPS or Satellite Images. OpenStreetMap is the culmination all of those sources. People around the planet are contributing to OSM through satellite images, raw GPS data and geo-referenced cadastral maps. OpenStreetMap is thus a wonderful resource that can be used into GIS applications and more over it is free!

Now, let us see how this could be done at the first level. Probably most of the leading GIS softwares uses PostgreSQL database with PostGIS extension to process geographic information. This note would help you to download the OSM data of the region of your interest and create a PostgreSQL database with duly applied postgis extensions. The database would fit into any GIS requirement as you expect.

A word about OSM layering of data. In OSM there are no layers in the traditional GIS sense. All features are in one big coherent
database. But still, when you are creating a database out of it, you are actually layering the entire data. More information on layering is available here.

Lets us begin with collecting the OSM data. There are many ways for you to download the OSM data sets. I prefer those from CloudMade. There are other sources like GeoFabrik. And of course the direct data sets from OpenStreetMap.org. The data might be in the default OSM xml style sheet which is called the .osm file.

Now that we have the data, we’ll use some tools to set the database up. Please ensure that you have PostgreSQL, PostGIS including the contrib packages. Osm2pgsql is the important tool which we would be using to straight away convert the OSM data set into a PostgreSQL database. You can install osm2pgsql from the source or packages listed here.

Next, we need to setup a database to load the OSM data. This could be done in the following steps.

$ sudo -u postgres createuser <username>

$ sudo -u postgres createdb -E UTF8 -O <username> <dbname>

$ sudo -u postgres createlang plpgsql <dbname>

Now add the postgis extensions. Note the location of the lwpostgis.sql file may vary.

3 thoughts on “OpenStreetMap and GIS: Bridging the gap.”

Excellent. Amazing
I can realize that how much work you have done to do all this,
Because i am also working on the similar project
This is just amazing that you shared it here.
It has helped me a lot.
Thank’s …