springmeyer / Quantumnik

Python integration of Mapnik with Quantum GIS.

Clone this repository (size: 256.8 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/springmeyer/quantumnik/

Quantumnik

Mapnik integration with QGIS

Supports on-the-fly translation of QGIS layers and styles into Mapnik objects, ability to export a QGIS project to a Mapnik XML mapfile, and the loading of Mapnik XML or Cascadenik MML/CSS for dynamic rendering in QGIS.

Requires a working installation of Mapnik (>= 0.5.1) (ideally >=0.6.0) and Mapnik built against the same version of Python used by QGIS.

Written by Dane Springmeyer

Screencasts of features available at: http://dbsgeo.com/

Changelog available at: http://bitbucket.org/springmeyer/quantumnik/src/tip/CHANGELOG.txt

Post problems to the Issues Page

Thanks to Aaron Racicot and numerous others for early advice, testing, and bug reporting.

New tabbed view and styled xml in Quantumnik added in 2.x series:

New tabbed view in Quantumnik

OpenStreetMap browser in QGIS via Quantumnik Plugin:

OpenStreetMap browser in QGIS via Quantumnik Plugin

Flickr Alpha Shapes from Clustr in QGIS via Quantumnik Plugin:

Flickr clustr shapes and Image Export in Quantumnik

Primary Features and Goals

  • Authoring of Mapnik XML via QGIS symbology interface (mostly implemented).
  • Ability to open a read-only Mapnik XML or Cascadenik MML file within QGIS for dynamic browsing (implemented).
  • Exporting bundle of datasources into sqlite datastore packaged with Mapnik XML for web rendering (not implemented).
  • High resolution export from QGIS via Mapnik rendering (work in progress).
  • Environment to test/improve Mapnik rendering and python API by comparing against PyQgis features (already a success!).

Roadmap

I'm looking for funding or other interested developers to support several major Quantumnik features:

  • Currently Quantumnik enables QGIS layer and style definitions to be converted to Mapnik definitions (in the form of an XML mapfile). A further step would enable true bi-directionality of styles and layers, so that existing Mapnik XML, MML, or Python styles could be translated into QGIS objects and then edited freely inside QGIS.
  • Currently QGIS has a one layer <-> one style object model, which makes variable zoom/scale based visibility of styles (a common need of Mapnik users deploying tilesets), impossible. Because Mapnik fully supports named, aggregate styles and multiple rules per style, work inside QGIS or within an external plugin dialog needs to happen to enable some kind an interface for creation of multiple styles per layer. See #8
  • Mapnik supports SQLite datasources since 0.6.0, and will hopefully soon support Map Pickling and the deepcopy of all Mapnik Python objects (http://trac.mapnik.org/ticket/345). Currently Quantumnik can export Mapnik XML, but a hugh advancement would be to support publishing styles along with an SQLite bundle of datasources. Publishing could include automatic re-projection of datasets into a target srs optimized for tile-rendering, automatic indexing of datasources converted into sqlite tables stored in a single SQLite db, and packaging of relevant styles as a pickled sidecar inside or beside the database.

Contact me about this or other ideas for future directions.

Requires

Mapnik installed on Linux, OSX, or Windows (Untested but may work on other platforms like Solaris).

Mapnik 0.5.1 (ideally >=0.6.0) with Python Bindings built against the same version of Python that QGIS uses.

  • Quantum GIS normally runs against Python 2.5 on Mac/Windows while it uses Python 2.6 on recent Ubuntu versions (Jaunty).

Installing Mapnik

Install Mapnik via the instructions at:

Testing Mapnik

Confirm your Mapnik install with:

Make sure you can do this within the QGIS Python Console (under Plugins menu), which will indicate whether Mapnik was installed against the same version of Python as QGIS.

1
2
3
$ python
>>> import mapnik
# no result is good!

Installing Quantumnik

Install the latest release of the plugin via the QGIS plugin manager:

  • Enable the Plugin Installer in the Plugin Manager
  • Choose "Fetch Python Plugins"
  • Add a new repository http://qgis.dbsgeo.com/
  • Quantumnik should then appear in your plugins list

Or install manually by cloning this repository with mercurial:

hg clone http://bitbucket.org/springmeyer/quantumnik/

And then copy the 'quantumnik' folder into your plugins folder, usually located at:

~/.qgis/python/plugins

Then enable in your plugin manager.

Using Quantumnik

  • Try loading some vector data and hitting the Quantumnik Icon to render with Mapnik.
  • Or load a Mapnik XML or Cascadenik MML file via the Plugin menu.
  • Extra options can be found in the Quantumnik Plugin Menu.

Post problems to the Issues Page

Caveats

Raster support requires at least Mapnik 0.6.0.

Vector support for datasources other than shapefiles requires Mapnik built with the 'ogr' plugin (not default)

  • use the flag 'INPUT_PLUGINS=all' when you build Mapnik with Scons.
  • Otherwise you will get an error like:
1
UserWarning: Could not create datasource. No plugin found for type 'ogr'

FAQ

I'm on windows reading shapefiles and getting an error like:

1
RuntimeError: failed opening file: The handle is invalid.

Solution: Upgrade to Mapnik 0.6.1

I'm on a Mac and tried to install the plugin but got:

#python
The plugin is broken. Python said:
dlopen(/Library/Python/2.6/site-packages/mapnik/_mapnik.so, 258): no suitable image found. Did find: /Library/Python/2.6/site-packages/mapnik/_mapnik.so: mach-o, but wrong architecture

Then you are likely on a newer Mac with 64 bit firmware running Snow Leopard. You compiled Mapnik yourself and by default gcc created an x86_64 (64bit) library but QGIS is lagging behind the wave and only supports running 32 bit.

You can download "FAT", 32+64 bit Mapnik binaries from here: http://dbsgeo.com/downloads/

If you are determined to build from source, then you'll need to rebuild Mapnik with 32 arch (or both 32 and 64 bit). Do this by passing the CXX argument to SCons:

#sh
$ python scons/scons.py CXX='g++ -arch i386 -arch x86_64'

}}}


This revision is from 2010-01-11 07:06