Banner

Saturday, 22 September 2012

Creating a custom map tiling scheme for New Zealand’s seafloor

First of all I want to thank Brent Wood at National Insitute of Water & Atmospheric Research (NIWA) for inviting me to their office after writing my first blog post about seafloor mapping in New Zealand. Luckily I happened to be in Wellington where they are located, the best city in New Zealand (see photos below)! I was also fortunate to meet Kevin Mackay, the Marine Database Manager who’s responsible for the bathymetry dataset I’ve been using to create this map. You’ll be surprised about the amount of work and data needed to create a bathymetry dataset for such a large and hidden area of our planet. This mapping has been beneficial to New Zealand, as they have been able to claim rights to 1.7 million square kilometers of extended continental seabed, an area about six times New Zealand’s total land area.

In the last blog post we created a seafloor map of New Zealand using shading relief. The map image we created was very large, 12000 x 15200 pixels, with a resolution of 250 meters per pixel. To create an interactive web map we need to cut the image into tiles for a number of zoom levels.  As I’m using a custom map projection (Mercator 41), I also have to define a custom tiling scheme. This is my suggestion:


The red area shows the extent of the dataset. The yellow squares show the tiles for zoom level 0 to 2. The biggest square covers an area of 4,096,000 x 4,096,000 meters.  Data nerds will know that this number is easily divided by 256, the de facto size of map tiles in pixels. The tile area is defined by these bounds (left, bottom, right, top): 4200000, -6096000, 8296000, -2000000. This table shows the resolution and scale for all zoom levels: 


Zoom level 6 is maching the resolution of our dataset, 250 meters per pixel. We now have the information we need to define the tiling scheme in TileCache:

[nz-seafloor]
type=Mapnik
src=EPSG:3994
bbox=4200000,-6096000,8296000,-2000000
maxResolution=16000
mapfile=/home/turban/NZ/Bathymetry/nz-seafloor.xml

I’m not going into detail here, read more about how you can define custom tiling schemes with TileCache, Mapnik and Leaflet in this blog post. I’m using tilecache_seed.py to render the map tiles: 

tilecache_seed.py -f nz-seafloor 0 7

Next, we can use Leaflet to load the tiles into an interactive map:


This is what the map looks like:



Show fullscreen

----

A few photos from the best captial city in the world, Wellington:


4 comments:

Hamish said...

Hey Bjørn, it was great to catch up with you briefly while you were in Auckland. Are you going to have time to stop by to try some more local IPAs? :P

Great looking map! I noticed however that you're missing a few offshore islands. LINZ have a combined polygon layer here, that you should be able to drop in as a replacement for the mainland and island polys:

http://data.linz.govt.nz/#/layer/1153-nz-coastlines-and-islands-polygons-topo-150k/

Includes notably missing island groups like the Chathams.

Bjørn Sandvik said...

Hi Hamish,

It was nice meeting you, I would definately like to try some more IPAs if I'm passing by Auckland again!

Are the Chathams that important?!? ;-)
I was looking at the 1:50,000 dataset, but the large scale data didn't fit my small scale map. Do you know if the same dataset is available at 1:500,000 scale? I couldn't find island polygons for lower resolutions at the LINZ Data Portal, so the one I'm using is converted from a line dataset using QGIS.

Hamish said...

Heh, well they often get left off, and people don't usually notice. I guess because we always have to deal with horrible anti-meridian problems, I've become used to looking out for it. Nokia maps completely ignores them too :(

There are about a 1,000 people who live there, and they're reasonably sized islands (a little smaller than Steward Island to the south). The Auckland Islands further south are significant too, but again, they're commonly ignored and uninhabited.

No, doesn't look like there is a 1:500,000 version. I'll ask them if they'll put one together :)

Hamish

DR said...

There is error in table - map size sould be 512x512 instead 512x256.