Development Seed
Development Seed
Published in
3 min readDec 18, 2008

--

By: Tom MacWright

As many of “you read earlier on this blog, we released Nice Map”:http://www.developmentseed.org/blog/2008/nov/18/hey-thats-nice-map-new-custom-mapping-module-drupal as a bridge for Drupal to better communicate with WMS servers. Jeff gave a nod to “NASA’s free server”:http://wms.jpl.nasa.gov/, which is a great source for beautiful surface imagery and an easy way to test WMS clients. However, the real benefit of mapping with WMS is that you can drop in any WMS-compliant server you like, and Nice Map and other clients will do the legwork of getting beautiful maps on your site. This opens up the possibility for completely custom, beautiful maps like we have on “Stumble Safely”:http://www.outsideindc.com/stumblesafely — maps that can set your site apart from the masses of Google Maps and match the zaniest color schemes. The level of flexibility offered by the WMS protocol and servers is an incredible boon for anyone doing online maps. Here’s one example of a custom map we built with this.

!http://farm4.static.flickr.com/3180/3097599549_f11c381ab1.jpg!

Luckily, there’s an open-source project, “Mapnik”:http://www.mapnik.org/ that makes building a WMS server into a matter of assembly rather than one of guesswork. In its earlier iterations, Mapnik gained a reputation for being a pain to install, but with the changes in 0.5 and up, it has become quite straightforward — dare I say, in some cases, easy. There are plenty of options for installing it: fastcgi, wsgi, TileCache, SVN or the packaged release, etc.

But if you’re using Mapnik in order to get a great WMS server, it’s nice to have an option with batteries included: this method puts all of the ingredients together: Mapnik, “lxml”:http://codespeak.net/lxml/ support for speed, “PostGIS”:http://postgis.refractions.net/ compatibility, patches for a few common issues, and a mod_python server so that you can run it all on Apache.

First, I’ll go over the basic server requirements for this solution. Put simply, it’s great for Debian or Ubuntu systems on dedicated or virtual private servers. There are installation instructions for “Windows”:http://trac.mapnik.org/wiki/WindowsInstallation and “Macintosh”:http://trac.mapnik.org/wiki/MacInstallation on Mapnik.org, but if you’re setting up a web server, Ubuntu is a great choice, and hosting companies like “Slicehost”:http://www.slicehost.com/ are making virtual private servers inexpensive, fast, and incredibly flexible. You’ll need about 140MB to build and install Mapnik if you don’t already have any of the required libraries and tools — in a fresh, minimal Ubuntu install, @apt-get@ brings the installed packages to 123MB.

So assuming that you’ve got an Ubuntu server where you can use “sudo” to do operations with root privileges, installing Mapnik is mostly a snap. I’ll go over the quick method first.

  1. Get mapnik_matic by checking it out from our repository
  1. Run the installation shell script with admin privileges*
  • In Ubuntu 7.x,
  • @sudo ./mapnik.sh@
  • In Ubuntu 8.x,
  • @sudo ./mapnik_8.sh@
  1. Edit @map.xml@, changing the path @/home/tom/mapnik_matic/GIS/@ to the path to your GIS directory
  2. Set up Apache according to the file @sample_apache_config.dev@. If you’re using virtual hosts, you can simply edit the paths indicated in the file, copy it into sites-available, and linking this file to sites-enabled.
  3. Restart Apache and try it out.
  • Note: This step, which includes compiling Mapnik from source, can take a very long time on SliceHost servers.

Here’s an example WMS request:

http://yourserver.com/wms.py?width=520&height=260&styles=Plain&bgcolor=0xa0acb8&request=GetMap&version=1.1.1&format=image/png&layers=world&srs=EPSG:3395&EXCEPTIONS=application/vnd.ogc.se_inimage&bbox=-179,-58.8110470437,179,72.092336216

If you get a rendered image, rejoice! Your WMS server is ready to go and ready to hook up to great clients like "Nice Map":http://drupal.org/project/nicemap and "qgis":http://www.qgis.org/.

Stay tuned for details on how to get Mapnik jiving with PostGIS!

A big "thanks to Troy at New America Foundation":http://statehealth.newamerica.net, a long time Drupal user who financed some of our initial work with Mapnik. Please get in touch with us if you are doing cool things with Mapnik and have some functionality that you think we should know about. And please post patches to "Nice Map":http://drupal.org/project/nicemap.

--

--

Development Seed
Development Seed

We believe in open source and in building for lasting impact.