7th July 2011

DHM25

The DHM25 matrix model elevation data, as available from SwissTopo (previosly Bundesamt für Landestopographie, L+T), is commonly seen in a data format known as MMBLT or MMBL. To play with that elevation data, it needs to be converted to something more useful, for example to a PNG heightmap which can directly be used by POV-Ray.

MMBLT to POV-Ray PNG Heightmap Converter

This perl script reads DHM25 level 1 or 2 matrix model elevation data from SwissTopo MMBLT (.mlt) or MMBL (.mbl) files. All grid sizes are supported (25/50/100/200/1000 meters). It can write the elevation data to a height map PNG file, using the full available precision of the data (ie. lowest data point is pitch black, highest data point is bright white).

To be able to scale the height map to its correct aspect ratio from within a scene, the script calculates scale factors for all dimensions, and reads some other useful information from the MMBLT/MMBL header.

For rendering the elevation data with their corresponding pixel map overlaid, the script provides convenience functionality to write a POV-Ray include file containing a POV-Ray object, scaled to correct aspect ratio, and translated to the natural position within the POV-Ray coordinate system (in km; x-axis is W/E, y-axis is N/S, inverted z-axis is height). This allows working with the convenient Swiss coordinate system within POV-Ray.

It is on my TODO list to further improve the generated POV-Ray include files, in order to get a more versatile library of DHM25 powered objects (height fields and overlay separately, maybe wireframe models). Stay tuned, and please feel free to contribute, as I’m no POV-Ray expert.

mmblt2pov.pl [OPTIONS...] [INFILE]

Read a DHM25 matrix model in MMBLT/MMBL format from INFILE or stdin, and
convert it to a more universally useful PNG height map and POV-Ray object.

        -m file   Write PNG height map to file
        -p file   Write POV-Ray object source to file
        -t file   Use file as texture image for POV-Ray object
        -o XXXX   Equivalent of -m XXXX_hm.png -p XXXX.inc -t XXXX.png
        -q        Be quiet
        -h        This cruft

If none of -m, -p and -o are given, no output will be written, but the
MMBLT header and data will still be parsed and checked.

To transform mm1091.mlt into corresponding 1091_hm.png and 1091.inc, use:
        mmblt2pov.pl -o 1091 mm1091.mlt

POV-Ray Examples

View towards the city of Zürich (683/500//248/000//500) including the Airport Zürich-Kloten, as seen from above the lake of Zürich (683/500//244/000//3000). Not very sophisticated, but a starting point nonetheless.

#include "1050.inc"
#include "1051.inc"
#include "1052.inc"
#include "1070.inc"
#include "1071.inc"
#include "1072.inc"
#include "1091.inc"

#declare SourceX = 683.5;
#declare SourceY = 244;
#declare SourceH = 3;
#declare TargetX = 683.5;
#declare TargetY = 248;
#declare TargetH = 0.5;

light_source
{
 <-1000+600,1000+200,-1000>
 rgb <1,1,1>
}
camera
{
 location <SourceX,SourceY,-SourceH>
 look_at <TargetX,TargetY,-TargetH>
 sky <0,0,-1>
}

DHM25 Data Files and Related Software

Unfortunately, DHM25 data is not freely available. You can purchase the data from SwissTopo. They do have some free test data available (at the time of writing, DHM25/25 Matterhorn and Albis, plus DHM25/1000 Switzerland).

Ƿ