Friday, October 14, 2011

Using OSM data in GeoServer: Part1 - PostGIS

The first thing we need is a data base to store spacial data. Today ever big vendor has a spacial extension that is compliant with the simple feature specification from the OGC.
We could choose from the following data bases:
Oracle, MSSQL, MySQL, Postgres, ...

I pick Postgres with its spacial extention called PostGIS. It is an stable open source data base with no costs. This is the only data base I know for which a tool exists to import the osm data. It is called osm2pgsql.
  1. Download and install PostgreSQL.
  2. Update or manually install PostGIS
  3. Create a spacial db called osm with a new user
  4. Configure the connections

1. Download and install PostgreSQL

Get the one click installer from the download page. I choose the version 8.4 instead of the 9.x branch because it gots all the funktionality we need and it is the most stable and secure version.

One click it : postgresql-8.4.9-1-windows.exe

The installer will promt you:
Installation Directory: C:\Program Files\PostgreSQL\8.4
Data Directory: C:\Program Files\PostgreSQL\8.4\data
Password: <your password>
Port: 5432

At the end you get asked if you want to launch the Stack Builder.
Choose from the category tree 'spacial extensions' and then 'PostGIS 1.5'.

Alternatively you can install the extention by hand. There are instructions at the PostGIS site.

Open up the 'pg Admin III' tool from your start menue. In the objectbrowser you will find a data base called 'template_postgis' with two tables 'geometry_columns' and 'spacial_ref_sys'. If you need a new gis data base you use this as a template. So don't alter it.


Create a new Login-Roll called osmuser by right clicking on 'Login-Rollen'.
Create a new gis data base by right clicking on 'Databases' in the Tree.
Name: osm
Owner: osmuser
Template: template_postgis
Finaly you have to assing the osmuser to the tables in the data base.

This can also be done by the postgres console.

Now you are ready with the basic data base setup. Next part will show you how to import the osm data.

No comments:

Post a Comment