Skip to main content

Creating a seafloor map using shaded relief

I'll use the bathymetry data from NIWA to create a seafloor map of New Zealand using shaded relief techniques. I used the same techniques when I created the terrain map of Jotunheimen in Norway, so I won't go into detail here.

Let’s start by creating a color relief of the seafloor. I’ve used a blue color gradient similar to the one used by NIWA, progressing from light shallows to dark depths.

Source: NIWA

gdaldem color-relief -co compress=lzw nz-bathymetry.tif depth-gradient.txt nz-bathymetry-relief.tif


I want to enhance the view by using a couple of hillshade techniques. Let’s create a plain hillshade with gdaldem:

gdaldem hillshade -alt 60 -az 135 -co compress=lzw nz-bathymetry.tif nz-bathymetry-hillshade.tif 

Notice that the light source (-az) is not from the default top left position (azimuth = 315°), but in a bottom right position (azimuth = 135°). The reason for this is that bathymetry data are inverted compared to elevation data, with higher depths having higher values.  


The problem with this hillshade is that it’s all grey, and this grey color will blend with our color relief.
To enhance the hillshade we can apply another technique. This technique is described in the document “Creating Slope-Enhanced Shaded-Relief Using Global Mapper” by Kent D. Brown at Utah Geological Survey. The technique clears out the gray from low-angle slopes so the map colors are not "muddied" by shading. The document describes how to do this in Global Mapper, but we’ll try to do the same the hard way with GDAL and Mapnik.

As described in my previous blog post, creating slope shading is a two-step process. First we need to create a raster from the bathymetry data where each pixel contains an angle, varying from 0 to 90 degrees as the seafloor ranges from horizontal to vertical:

gdaldem slope -co compress=lzw nz-bathymetry.tif nz-bathymetry-slope.tif  

Secondly, we use this raster to slope shading by assigning a color to each pixel, using the same technique as for color relief. What we’ll do is to turn all slopes of 0° white, and any slope above 5° black. Anything in between will be in various shades of gray. Adding these two lines to the configuration file will do the trick:

We can then create slope shading with this command:

gdaldem color-relief -co compress=lzw nz-bathymetry-slope.tif slope-ramp.txt nz-bathymetry-slopeshade.tif 


Next we can use Mapnik to combine the hill- and slope shade:

nik2img.py nz-bathymetry-hillslopeshade.xml nz-bathymetry-hillslopeshade.tif -d 12000 15200 



Lastly, we can combine this enhanced hillshade with the color relief, together with a few datasets from LINZ Data Service:


nik2img.py nz-seafloor.xml nz-seafloor.tif -d 12000 15200 --projected-extent 4800000 -5900000 7800000 -2100000



In my next blog post, I'll turn this image into an interactive web map. 

Comments

Anonymous said…
I still think GMT can do the same thing, but looks nicer & is only a few lines of code.

Brent Wood
Karl said…
Hi Bjørn,
I recognize your DEM to be of positive values, right?
My sea bed DEM in use (IBCAO 3.0 http://www.ngdc.noaa.gov/mgg/bathymetry/arctic/) have negative and positive values - the negative are of most interest here.
My hillshade generation seems to be flattened for the negative areas.
What should I do in this case - I haven't found anything useful on the internet so far.

And thanks for the useful tips around.

Karl Zinglersen
Paul Greer said…
Awesome stuff, thanks.

Popular posts from this blog

Creating a WebGL Earth with three.js

This blog post will show you how to create a WebGL Earth with three.js , a great JavaScript library which helps you to go 3D in the browser. I was surprised how easy it seemed when reading a blog post  by Jerome Etienne . So I decided to give it a try using earth textures  from one of my favourite cartographers, Tom Patterson . WebGL is a JavaScript API for rendering interactive 3D graphics in modern web browsers without the use of plug-ins. Three.js is built on top of WebGL, and allows you to create complex 3D scenes with a few lines of JavaScript. If your browser supports WebGL you should see a rotating Earth below: [ Fullscreen ] To be able to display something with three.js, you need three things: a scene, a camera and a renderer. var width  = window.innerWidth,     height = window.innerHeight; var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(45, width / height, 0.01, 1000); camera.position.z = 1.5; var rende...

Thematic Mapping Engine

It's time to introduce the Thematic Mapping Engine (TME). In my previous blog posts, I've shown various techniques of how geobrowsers can be used for thematic mapping. The goal has been to explore the possibilites and to make these techniques available to a wider audience. The Tematic Mapping Engine provides an easy-to-use web interface where you can create visually appealing maps on-the-fly. So far only prism maps are supported, but other thematic mapping techniques will be added in the upcoming weeks. The engine returns a KMZ file that you can open in Google Earth or download to your computer. My primary data source is UNdata . The above visualisation is generated by TME ( download KMZ ) and shows child mortaility in the world ( UNdata ). The Thematic Mapping Engine is also an example of what you can achieve with open source tools and datasets in the public domain: A world border dataset is loaded into a MySQL database . The same database contains tables with statistics ...

Creating 3D terrains with Cesium

Previously, I’ve used three.js to create 3D terrain maps in the browser ( 1 , 2 , 3 , 4 , 5 , 6 ). It worked great for smaller areas, but three.js doesn’t have built-in support for tiling and advanced LOD algorithms needed to render large terrains. So I decided to take Cesium for a spin. Cesium is a JavaScript library for creating 3D globes and 2D maps in the browser without a plugin. Like three.js, it uses WebGL for hardware-accelerated graphics. Cesium allows you to add your own terrain data, and this blog post will show you how. Impressed by the terrain rendering in @CesiumJS - with a 10m elevation model for Norway! Farewell Google Earth. pic.twitter.com/RQKvfu2hBb — Bjørn Sandvik (@thematicmapping) October 4, 2014 Compared to  the dying Google Earth plugin , it's quite complicated to get started with Cesium. The source code is well documented and the live coding Sandcastle is great, but there is a lack of tutorials  and my development slows down when ...