use mapnik to render osm data from a geocouch db
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is a little project demonstrating how to render maps with mapnik and geocouch.



Read the documenation of the driver:

First of all you should install gdal. Make sure the couchdb driver is part of the source code. I'm using the latest driver from the gdal svn:

Make sure you installed all dependencies (curl library) before you do a:

./configure && make && sudo make install


Now let's install the latest mapnik code with python support. Clone the repository form github and do a:

./configure && make && sudo make install


Installing geocouch is a bit tricky but possible. In order to get a working setup you have to install couchdb 1.1.x as well as the geocouch branch for 1.1.x. Let's clone couchdb and switch to the right branch:

git clone
git checkout 1.1.x

Now let's build couchdb (again make sure to install the dependencies):

./bootstrap && ./configure && make && sudo make install

Cool. Now let's install geocouch:

git clone
git checkout couchdb1.1.x

Follow the instructions in the README of geocouch to build geocouch and install it.

Mot important steps:

Export the couchdb source directory:

export COUCH_SRC=<vanilla-couch>/src/couchdb

Use the make file to build geocouch:


Maybe you want to test the geocouch code:

make runtests

Copy the geocouch.ini file to the appropriate directory:

cp <geocouch>/etc/couchdb/local.d/geocouch.ini <vanilla-couch>/etc/couchdb/local.d/

Maybe you want to install the futon tests to check your setup...

Anyway, start couchdb with something like:

sudo ERL_FLAGS="-pa /tmp/geocouch/build" /usr/local/bin/couchdb


For the import of osm data we use geocouch branch of imposm. Make sure you have mercurial installed.

hg clone
cd imposm
hg checkout geocouch

Maybe you want to create a virtual environment for imposm.

virtualenv env
. ./env/bin/activate

Install imposm into your virtualenv.

python install

Import data

First of all create a new couchdb database:

curl -X PUT http://localhost:5984/osm

Use imposm to parse an osm file:

imposm --read berlin.osm.pbf

Now use the default imposm mapping which ships with this tutorial to import some data.

imposm --write -d osm -m

This should result in some data in your couchdb database.

Add metadata files and spatial views.

Open localhost:5984/_utils in your browser. Move to your database and add a design document. Source for the metadata design document should look like this:

   "_id": "_design/ogr_metadata",
   "srs": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS
   "geomtype": "GEOMETRY",
   "geojson_documents": true,
   "extent": {
       "validity_update_seq": 0,
       "bbox": [
   "fields": [

Add a spatial view to the design documents to enable spatial requests:

   "_id": "_design/ogr_spatial",
   "spatial": {
       "spatial": "function(doc) {if (doc.geometry){emit(doc.geometry,

Render a map

Use the provided script to render an tile. Maybe you want to adjust the extent which we render.

Style file

Take a look at the style file! Most important part:

  <Parameter name="type">ogr</Parameter>
  <Parameter name="string">couchdb:http://localhost:5984/</Parameter>
  <Parameter name="layer">osm</Parameter>

String is the hostname of your couchdb instance and layer is your couchdb database.