mapnik datasource plugin for reading geodata from mongodb
C++ JavaScript
Latest commit 65f395d Sep 22, 2013 Dane Springmeyer Merge pull request #1 from hamer/master
MongoDB connector for points, lines and polygons
Failed to load latest commit information.
.gitignore added shp -> mongodb importer Sep 20, 2013
Makefile the term "hemisphere" now understands right Sep 22, 2013
mongodb_converter.cpp typo fiz Sep 19, 2013
mongodb_datasource.cpp the term "hemisphere" now understands right Sep 22, 2013
mongodb_featureset.hpp my code upload (not tested yet) Sep 19, 2013

MongoDB input plugin for Mapnik

This is a connector to MongoDB data in the form of a Mapnik C++ plugin. MongoDB supports spatial indexig on a sphere for a Points, a LineStrings and a Polygons since version 2.4.


Input plugin accepts the following parameters:

  • host -- (optional) hostname to connect MongoDB [default: "localhost"]
  • port -- (optional) port to connect [default: 27017]
  • dbname -- (optional) database name to use [default: "gis"]
  • collection -- (required) collection to use

Example in XML:

    <Parameter name="type">mongodb</Parameter>
    <Parameter name="collection">polygons</Parameter>

Records in the database should have a "geometry" property with GeoJSON geometry (only Point, LineString and Polygon are supported), and a "properties" property, which contains an information about feature.


    geometry: {
        type: "LineString",
        coordinates: [ [ lng1, lat1 ], [ lng2, lat2 ], ... ]
    properties: {
        name: "Long Hard Road",
        id: 32167,

CAUTION: notice the Longitude, Latitude order.


Render result for test/test.js, source shape files in QGis screenshot:

west east


1) Install MongoDB with C++ driver (libmongoclient)

Recommended to install from

git clone
cd mongo
git checkout r2.4.6
scons --full install

2) Start MongoDB

In another terminal:

mkdir db
cd db
mongod --dbpath .

3) Prepare test environment (optional)

The tests are written in Node.js v0.10.x for Mapnik v2.2.x.

cd test/
npm install mongodb mapnik

4) Import a shapefiles to the database

In another terminal:

node import.js

5) Run test.js

node test.js