There’s an amazing amount of free mapping code and data out there but
it’s difficult to figure out how it all fits together. Yesterday I did a
one day
spike of
a map for pilots, a picture that emphasizes
mountains higher than 8000′. What I love about this hack
is how much technology was involved. Web servers, Javascript, PNG
compositing. Geographic projections and image rendering. Data from
three different sources, including the freaking
Space
Shuttle. And I was able to cobble it all together in less than a day
without any real expertise in mapping. Hooray for
Open Source Geo!
My product is a slippy map, a
zoomable javascript map like Google Maps. The map has three data layers
on it: raster aviation sectionals for the base map, a raster elevation
overlay, and a vector state outline. I
put it all together in Javascript using Polymaps, an amazing mapping library.
All told it was 50 lines of Javascript, about an hour’s work.
Polymaps’ job is loading map tiles, what about the tiles themselves?
I lifted the aviation sectionals from RunwayFinder and the state
outlines from a
PolyMaps demo. I had to build my own map layer for elevation. SRTM is an amazing free
elevation dataset (7GB for North America, an hour’s
download). But it’s just raw data and I need images.
SRTM is a simple enough format but I didn’t want to write a bunch of
rendering software. Fortunately there’s MapServer, a dynamic web server for map
tiles. MapServer wraps a CGI interface around GDAL, which does the heavy lifting of
projection, scaling, and rendering (via libgd). The great thing about
this software is it all just works and has great
docs. I barely understand what it’s doing, but I got it working with
an hour or two of tinkering.
I didn’t link my live map because my server would die; the dynamic
rendering from Mapserver is too much for it. It’d be pretty simple to
prerender all the SRTM tiles to about 100 gigs of image files for
fast serving. That’d be a useful resource to host online for other
mappers to use in their own products. But what I really want to do is
move that 8000′ threshold I hardcoded into the user’s hands, to let you
dial up and down and quickly see terrain levels. To do that requires
some client side image manipulation, so that’s my next hack.