Slippy map tile image format

Now that I have sample tiles from my SRTM data, what format do I want to store them in?

An 8 bit paletted image is sufficient. I really only need 2 colours: transparent (below 8000′) and white (above 8000′). All the other colouring is just so it looks nice. (May save space using 64 or 128 colours). Even GIF would work, but I think PNG-8 (color type 3) is a better choice. Interestingly, even palettized PNGs support a full alpha channel for all 256 colours, see the tRNS chunk.

Do all the tiles need to have the same palette? They can, since it’s the same colormap for all the images. Not sure how to convince GDAL / other tools to reuse the palette, though, particularly with the transparency data. I’m guessing I’m going to need a post-processing step after GDAL generates the final slippy map tiles. Maybe that final PNG baking step is the time to enforce a single palette. The other processing I want to do is optimize via one of pngslim pngnq pngcrush optipng advpng. A quick test shows optipng saves 50%, I think by translating 24+8 bit images to 8 bit paletted images. I swear I saw a map hacker’s notes on comparing these tools once.

One related idea I’ve had for awhile: it’d be awesome to make a set of SRTM tiles that were a simple greyscale, 0-255, and then remap them to full colour + transparency in Javascript, in the client. That way the user could quickly choose what altitudes to highlight. I think it’s barely possible using the canvas API, not sure if it’s a good idea.