HomeHome ArchiveArchive

Shaded relief maps with QGIS

Creating a shaded relief map from digital elevation data is a nice way to create a backround map for web mapping or other GIS work. Thanks to the know-how and the funding from the Swiss Humanitarian Aid Unit, QGIS now has a sophisticated function for relief map generation. The method is described in detail in an paper by Marc-André Bünzli. An important part of the method is the choice of the elevation colors. The QGIS plugin has the possibility to analyse the frequency distribution of the elevation values in the DEM and to propose color changes where significant changes in the histogram occure. It is of course also possible to modify the color scheme, to insert a completely different one in the dialog or to generat a shaded maps without color.

screenshot

As illustrated below, the relief map is composed by three components modulated onto the final map to give it a more three-dimensional appearance. These intermediate steps are shown here to get a better understanding of the method. In QGIS, the user directly gets the combination as a result.

  • The first component consists of a hillshade from north-west (300 degree) and an elevation color

screenshot

  • The second component is a hillshade and a gray value depending on the slope angle (darker is steeper). The hillshade angle of this second component differs to the first component by 15% to have better contrast in faces towards the light source. The second component is merged to the relief map with 30% weight.

screenshot

  • The third component consists of a hillshade from 270 degree and a yellow color in cells facing towards the light source. It is merged to the relief map with 10% weight

screenshot

And the final relief map looks like this:

screenshot

Raster resampling in QGIS

QGIS already offers a lot of possibilities to visualize raster data (contrast enhancement, color map, handling of transparent pixels, …) Last year, Radim Blazek refactored the raster provider interface and added on-the-fly reprojection support for rasters to QGIS. Very cool!

One of the few things currently missing in QGIS raster layer is the possibility to have other resampling types than nearest neighbour. The problem is that rasters appear pixelated when zooming further than the source raster resolution. So for applications like web mapping, it is important to interpolate the pixel colors and to have a broader display scale range for layers. In the last few weeks, I’ve added bilinear and cubic raster resampling to QGIS (thanks to Canton Solothurn for funding these activities!).

A lot of refactoring was necessary in the raster layer code to add resampling in a clean way. Therefore these changes are available in branch ‘raster_resampler’ of the QGIS github clone (<git://github.com/mhugent/Quantum-GIS.git>). It probably needs a longer period of testing to make sure every feature of the raster layer class still works properly.

The resampling option can be chosen in the raster properties dialog:

screenshot

And here is the effect for a three band color image.

Nearest neighbour:

screenshot

Bilinear:

screenshot

Cubic:

screenshot

And here for a palletted background map

Nearest neighbour:

screenshot

Bilinear:

screenshot

SMTP death penalty for Ebuyer.com

For an unknown reason Ebuyer.com was spamming me for years and wouldn’t take me out of their spam distributor. So now they’re blacklisted on the SMTP level. No more spam to any of us or any of our customers/domains.

mail:~# cat /etc/exim4/local_sender_blacklist 
*@*ebuyer.com

Bye bye Ebuyer spam

per user X11 options

One would expect that considered the complexity of gdm there would be a way to have per user X11 options. So no, there isn’t one. At least not after the great rewrite after V2.22.

However good old Unix paradigms can help us (this is all under Debian, other Unices will allow a similar trick):

$ vim /usr/local/bin/X

Add something similar like this:

#!/bin/sh
#
# start X with different options depending on user

# check if the parent gdm process that started us contains
# "--username le_gamer" in its commandline
#
if ps -p $PPID -o args= | grep -q 'username le_gamer';
then
  exec /etc/X11/X.orig $* -config /etc/X11/xorg.conf.le_gamer
else
  exec /etc/X11/X.orig $*
fi

We check whether gdm is starting us and using the parameter “–username le_gamer”. If it is, then we’re using a different config file for X.

Of course you’ll need to adapt all this, unless you are using Debian or Ubuntu. You need to adapt the path to the X Server, to the config files etc.

Why did I do that? The problem is that Intel’s X server in Ubuntu Lucid Lynx 10.04 is really unstable with DRI on a Intel GM965/GL960 graphics card.

So unless I’m playing 3D games which are a lot faster with DRI, I don’t want to enable DRI (more over, “NoDRI” is pulling less power out of my battery). So my normal config contains this:

$ cat /etc/X11/xorg.conf
[...]
Section "Device"
        Identifier      "Configured Video Device"
        Option          "NoDRI"
EndSection

So now, the only thing you need to do is replace your “normal” X Server with the new “adaptable” one:

$ sudo mv /etc/X11/X /etc/X11/X.orig
$ ln -s /usr/local/bin/X /etc/X11/X

That’s it,

Tomáš Pospíšek