Making a Big OSM Map
Mapnik is a great tool. It allows for all kinds of neat toys to happen, and the recent work in SVN has really opened up the possibility that Mapnik might be a potential solution for a rendering engine in a lot of areas that it has previously left alone. (Support for reading OGR datasources, sqlite/spatiallite plugins, etc. are all great developments that look likely to be released in the upcoming 0.6 release.)
In prep for the OpenStreetMap Mapping Party this Saturday and Sunday in Somerville, I was working on printing a big map to bring with me. A friend at the Media Lab was gracious enough to help me out.
Using Mapnik, it was trivial to produce a large — 29750 x 29750 pixel — PNG image. This was designed to fill up the 49.5″ by 49.5″ printer space at 600 dpi.
The printer prefers PDF, PS or TIFF. I was able to take that PNG and convert it to a TIFF — but the resulting tiff was DEFLATE compressed, and the printer help only mentioned LZW compression. I decided to fall back to trusty GDAL to try to fix this. I found that the imagemagick-converted TIFF had one giant block — and GDAL was not pleased with this at all. (Its internal un-blocking scheme doesn’t work with compressed tiffs.)
Thanks to a suggestion from Norman Vine, I was able to use the ossim image copy program (icp) to convert this giant tiff to a tiled tiff which gdal could easily read: icp tiff_tiled -w 256 image2.out.tiff image.icp.tiff. Once I had done this, I recompressed the tiff using LZW compression with GDAL: gdal_translate -co COMPRESS=LZW image.icp.tiff image.lzw.tiff, and was able to upload the 3GB image to the printer.
All in all, took a bit more than I was expecting, but I’ve got a 4ft by 4ft map to bring to the mapping party this weekend. In the process, I also got to wanting magnification in Mapnik… which is amusing since just 24 hours before, I’d read a thread on the MapServer list and couldn’t imagine for the life of me why such a thing mattered.
Looking forward to showing the map off to local OSMers at the mapping party!
February 12th, 2009 at 12:43 pm
But where is the picture of the printed map?
February 12th, 2009 at 12:57 pm
In the post, now.
February 12th, 2009 at 2:07 pm
Why didn’t you use svg (or pdf, don’t know if that exists by I would suspect so knowing it’s cairo behind the scenes) output? this would seem the perfect output for the task, and you wouldn’t have to worry about the magnification stuff.
February 12th, 2009 at 2:22 pm
1. I couldn’t get Mapnik to build. I’ve never built Mapnik under Debian Stable; I use Debian packages, but there hasn’t been a release since Cairo support was added. So I didn’t have the ability to render to a Cairo surface.
2. Since I was ‘printing’ the image at 600dpi natively, I don’t think this would have changed anything. Had I, instead, printed at 90dpi and let the printer resize it, it probably would have worked, but I didn’t realize that what I had wouldn’t work until after it was already done.
3. “printing” that area at 90dpi or what have you would have left out a lot of the details that I wanted to see; Since the goal was really to get a coverage map, I wanted to see everything, and ‘zooming out’ by a factor of 6 leaves out a lot of the lower level names and so on. In this case, I couldn’t see them anyway, but with magnification of some kind I would.
4. The printer doesn’t cleanly support all versions of PDF, so I wasn’t sure that printing to a Cairo PDF would work.
5. Since rasterizing to png required 3GB of memory, I’m not *entirely* sure that vectorizing via Cairo would have been able to complete under the 32bit binary of Mapnik I have built.
In theory, though, that’s not an unreasonable question; I just don’t think it would have solved all my problems in this case. (the first not being solved by magnification anyway, because I still can’t compile Mapnik :))
February 12th, 2009 at 3:21 pm
I finally compiled mapnik on Debian for the first time recently – I had to compile Boost from source in order to get it to work, I think there are some notes from this process I posted to mapnik-users when it finally worked.
November 6th, 2009 at 9:49 am
Whoow that is a gorgeous map! I’m so jealous 🙂
You wrote that it is trivial tu make big image using Mapnik but for us who have no experience using Mapnik some pointers would be a huge help so that we can also make big images for our Mapping Parties.
Cheers from Croatia.