As many of you read earlier on this blog, we released Nice Map as a bridge for Drupal to better communicate with WMS servers. Jeff gave a nod to NASA’s free server, 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 – 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.
Luckily, there’s an open-source project, Mapnik 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 support for speed, PostGIS compatibility, patches for a few common issues, and a modpython 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 and Macintosh on Mapnik.org, but if you’re setting up a web server, Ubuntu is a great choice, and hosting companies like Slicehost 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.
- Get mapnik_matic by checking it out from our repository
svn co https://svn3.cvsdude.com/devseed/sandbox/mapnik_matic/
- Run the installation shell script with admin privileges*
- In Ubuntu 7.x,
- In Ubuntu 8.x,
- In Ubuntu 7.x,
map.xml, changing the path
/home/tom/mapnik_matic/GIS/to the path to your GIS directory
- 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.
- 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:
Stay tuned for details on how to get Mapnik jiving with PostGIS!
A big thanks to Troy at New America Foundation, 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.