This will give a short overview about how to create suitable input for Therion to get a nice 3D view in Loch. The text here is at the moment work in progress.
There are two main freely available datasets of elevation data. The first one is the dataset from NASA that was gathered during the SRTM (Shuttle Radar Topology Mission). They provide world wide elevation data (only the poles are missing, but there are not that many caves) with 3 arcsec resolution (around 90m). Only for the US they provide the data with 1 arcsec resolution (around 30m). Both data sources contain the data in a latitude longitude grid and therefore conversion of the data is needed.
The second source is Viewfinderpanoramas. The data is limited but for example for the Alps you get the data also with 1 arcsec resolution.
For overlay graphics you can use many possible sources like satellite images, aero photos or topographic maps. The main problem is that there is only limited freely accessible data. There is the data from the Landsat satellite, but the maximum resolution is around 15m/pixel (pan sharpened images). And these are not “real” coloured images as some information is lost by the earth atmosphere. Some countries like Germany or Austria provide data via WMS (Web Map Service). My examples will use that service. Some other countries provide data via ECWP which is a special protocol to transfer highly compressed maps or orthophotos via the web. That protocol protocol was introduced by Ermapper. But there are also freeware tools to access that data (mainly interesting for people in Italy, Spain and the UK.
You'll need some knowledge about coordinate systems to convert the input data. The EPSG (European Petroleum Survey Group) provides a list of coordinate systems. When you know the EPSG numbers of your input and output data the conversion is easily done. Here a list of some common systems:
|Gauss Krüger Zone 2||31466|
|Bundesmeldenetz BMN M28||31284|
|WGS84 UTM Zone 31N||32631|
|NZ Map Grid 1949||27200|
|NZ Transverse Mercator 2000||2193|
The last two digits at the UTM code define the zone.
Full table you may find at: therion/extern/proj4/nad/epsg
You will need some extra software to prepare the data for use in Therion/Loch. But there are freeware tools that can do the job. For MacOSX you'll find intall packages of frameworks at: Kyngchaos page.
The GDAL utilities is a nice collection of tools to handle geodata (raster based). I'll give here a short overview which tool is suitable for what job, for details please read the manuals available under the link above. For installation I would recommend the FWTools suite which provides pre build binaries. The detailed usage will be given in the examples, but it will help to read the mauals on the GDAL webpage.
All tools will report how to use them when called with −−help on the command line.
gdalinfo will give you information about a specific file. It extracts the georeferentiation and other (maybe) interesting things.
gdal_translate can transform your data from one image format to another one. It is also possible to extract part of the image.
gdalwarp will transform your data/image from one coordinate system to an other one. It can also perform interpolation. Limiting the output extent to a user defined area is also possible.
gdal_merge allows you to join multiple input files into on output files. This works for height data (srtm) as well as for regular images (ortho photos, topographic maps, …) as long as they are correctly georeferenced.
The first example will be a mountain in southern Germany. In detail it will be the Sontagshorn. As coordinate system I will use the local Gauss Grüger, zone 4, the corresponding EPSG code is 31468. The bounding box results in north: 5286980, south: 5279000, west: 4549000 east: 4556980 and is therefore of the size 7980×7980 m. The width/height was chosen as a multiple of 30m which is the resolution of the height model.
The example region is covered by the tile N47E012. For further processing you need to unzip the file. The conversion is done by:
gdalwarp -t_srs EPSG:31468 -te 4548985 5278985 4556995 5286995 -tr 30 30 -r cubic N47E012.hgt dem.tif
- -t_srs EPSG:31468 specifies the target coordinate system
- -te target extent: x_min y_min (SW) x_max y_max (NE)
- -tr 30 30 target resolution (here 30 x 30 meter)
- -r cubic cubic interpolation (cubic usually gives reasonable results)
You see that the bounding box was extended by half of the resolution. Therion defines the cell center of one grid element. To get the height field exactly over the edge of the overlay graphic this extension is needed. A intermediate file named dem.tif is created, this is needed as gdalwarp does not support the ascii output format. The conversion to ascii format is done by:
gdal_translate -of AAIGrid dem.tif dem.txt
- -of output format (here ArcInfo Asci Grid)
For usage in therion you need to delete the first 4 lines of that text file as they contain the bounding box.
Inclusion in therion
surface # declaration of the height model grid 4549000 5279000 30 30 267 267 # grid x_minimum y_minimum x_resolution y_resolution n_columns n_rows # followed by the matrix of the elevation data (from dem.txt): 1123 1234 ... ... # (data not shown completely) endsurface
To enable output of the 3D model you also need to edit your .thconfig file. This command enables output in the lox format:
export model -o model.lox
- -o output file name
You can now process the data, the surface will be displayed in grey colour as now surface texture is defined.
In Germany you can access quite some geographic data by WMS (web map service). The base url for the service in Bavaria (where the Sonntagshorn is located) is:
In a first step we need to ask the server which maps (layers) the servers provides:
The result is a xml data file (plain text file that you can open in any text editor). The supported data formats are listed after the Tag <GetMap>. I will use the format JPEG. The line <SRS>EPSG:31468</SRS> tells us that the server provides the data in the correct coordinate system. When you look further through the file you'll notice the names of the layers. Interesting is the layer DOP which is the Digital Ortho Photo and the layer TK50, a topographic map in the scale 1:50000. We can access a map by the following url (any web browser can be used):
- REQUEST=GetMap request is a map
- VERSION=1.1.1 software version
- SERVICE=WMS which service to use (Web Map Service)
- LAYERS=TK50 name of the layer
- SRS=EPSG:31468 the coordinate system to use
- BBOX=4549000,5279000,4556980,5286980 bounding box
- WIDTH=1995 number of pixel in east-west (maximum 2000 pix, may be different on other servers)
- HEIGHT=1995 number of pixel in north-south (maximum 2000 pix, may be different on other servers)
- FORMAT=image/jpeg graphic format
Save the resulting image as overlay.jpg
Inclusion in therion
We need one more line in the example (compare to the example above):
surface # declaration of the height model grid 4549000 5279000 30 30 267 267 # grid x_minimum y_minimum x_resolution y_resolution n_columns n_rows #bitmap "file name" [ x y X Y xx yy XX YY] # small letters in picture coordinates (0 0 is lower left and capital letters in real coordinates (X Y) bitmap ./overlay.jpg [0 0 4549000 5279000 1995 1995 4556980 5286980] # followed by the matrix of the elevation data (from dem.txt): ... # (data not shown here) endsurface
Patching of elevation data
It is also not really difficult patch the elevation data when your region is covered by two (or more) files. A simple example: you need to patch the 2 files N47E012.hgt and N47E013.hgt. First we need gdal_merge (again from the GDAL utilities) to merge these two files into one that we then can use for warping:
gdal_merge -o N47E012E013.tif N47E012.hgt N47E013.hgt
- -o output file name followed by multiple input files
This creates a tif-file which contains the elevation data (as integer values), most image displaying software displays these format not correct (as there is no colour map definded) and it will display completely black, but this does not matter. If you are unsure run
gdalinfo -mm N47E012E013.tif
- -mm display min/max values as well
and you will get the basic geographic information about the file (coordinate system, ellipsoid, bounding box, resolution, …).
For further processing just use this tif-file as input for warping (see above).
other input as mentioned above
GDAL can read (and write) a lot of different formats. gdalinfo is always your friend when you get new data.
self scanned maps
GDAL can also help you to georeference your self scanned maps. In a first step you need known points on the map in pixel coordinates and real coordinates. Then you add these points with gdal_translate with the −gcp pixel line easting northing. You can use OpenEV which comes with the FWTools to write down these coordinates. The next step would be gdalwarp to rectify the image. See online documentation for further help. I think this goes too far for the therion wiki.
questions & remarks
First of all, feel free to edit this page! Otherwise you can send emails to the therion mailing list or contact me directly wollez (äht) gmx (doht) net .
TerrainTool seems to be an easier Alternative
It does all the complicated stuff, and produces output as a .th file. Some offset my be needed for the co-ordinate system being used.
If it locks up on you, try deleting the file terrain.properties from the folder that contains the applications *.jar file. Next time you run it, it creates a replacement and seems to work fine (You will have to re-enter your defaults again).