# Scenery:Terrain.cfg File

## Terrain configuration file

This file is the main configuration for a terrain block. By convention, this file is usually named \texttt{terrain.cfg}. In the following example we look at a block of the Alps.

# Common section
tile_size_n = 1920
tile_size_e = 1920
start_n     = 43.5
start_e     = 5.5
ref_lat     = 50.0
num_tiles_n = 64
num_tiles_e = 64

img_cache_sz = 200
cell_size = 90
input_dir {
path   = /exthd/geodata/srtm30
ext    = .DEM.gz
pri    = 0
}

input_dir {
path   = /exthd/geodata/Alps/srtm
ext    = .hgt
pri	 = 1
}

# Terrain generator section
tolerance = 1.5


## Terrain area section

The first section describes the area of this terrain block. The \texttt{tile\_size} parameters determine the size of each tile in the terrain, in meters. The size in east direction depends on the latitude of the tile as described in the previous section, so this size is only correct on the reference latitude given by \texttt{ref\_lat}.

Usually we recommend setting the tile size equal in east and north directions. Usually we select a size which matches the highest resolution textures available for the terrain block. In this example we have 15m/pixel textures of 128$\times$128 pixels, which gives tile a size of $15 \times 128 = 1920m$.

Next we have the lower left corner of the block given in decimal degrees, in this case 43.5\degrees N and 5.5\degrees E. The reference latitude \texttt{ref\_lat} is set to 50\degrees N.

The \texttt{num\_tiles} parameters determine the number of tiles in each direction. As mentioned above, these values should normally be equal and power of two.

## Data input section

The next section contains a few common parameters and a set of blocks determining the input elevation data for terrain model.

The first common parameter is \texttt{img\_cache\_size} which sets the maximum amount of memory (in Mb) used by the data reader. If you have a lot of memory you can set this quite high to increase the efficiency of the data reader process.

The other common parameters is \texttt{cell\_size}. This parameter determines the maximum resolution of the input data. In our case we use SRTM data with 90m grid spacing, i.e the cell size is set to 90m.

## Data input blocks

To create a terrain model we need at least one set of input elevation data. These data sets are usually given as regular grids (raster) of elevation values. Each data set is described by a \texttt{data\_dir} block, enclosed in curly brackets, \texttt{\{} and \texttt{\}}.

In our example we have two input data sets, a coarse 1km grid taken from the global SRTM30 data set, and the more detailed 90m grid, taken from the main SRTM data set. \footnote{For more info on the SRTM data

 sets, see \texttt{http://www2.jpl.nasa.gov/srtm/}}.


These data sets are prioritized with the \texttt{pri} parameter so that the higher detailed SRTM data set has higher priority than the SRTM30 data set. This means that if we have coverage from both data sets in an area, the highest priority data set is used. The \texttt{path} parameter is the full file path to the directory containing the input data files, and the \texttt{ext} parameter is the filename extension of the data files. All files in the directory with this extension will be used.

The following table describes all valid parameters in a data set block.

\begin{table}[htbp]

 \begin{center}
\begin{tabular}{ l  p{6.5cm} }
\hline
\texttt{path = <file path>}	& Full path to input data directory.\\
\texttt{ext  = <n>}	& File name extension of data files. (See below) \\
\texttt{pri  = <n>}	& Priority of data set. Higher values mean higher
priority.\\
\texttt{recursive = <true|false>} & If true, all subdirectories of
\texttt{path} will be checked for data files.\\
\texttt{coosys = <proj4 def.>} & Coordinate system and projection as a
used in the PROJ4 package (see below).\\\hline
\end{tabular}
\end{center}


\end{table}

### Supported file formats

The GeoGFX terrain generator supports a variety of input data formats as shown in the following table. \begin{table}[htbp]

 \begin{center}
\begin{tabular}{ l  p{6.5cm} }
\hline
\texttt{.tif}	& Either GeoTIFF or regular TIFF files with an ArcView
type world file, \texttt{.tfw}\\
\texttt{.asc}	& ArcInfo ASCIIGRID format.\\
\texttt{.dt1}	& DTED Level1 fomat.\\
\texttt{.hgt}	& Raw SDTS format.\\
\texttt{.dem}	& USGS DEM format or GTOPO30 DEM files.\\
\texttt{.ddf, tar, tgz} & USGS SDTS DEM file. These data sets can be
accessed directly from their tar archives for convenience.\\
\texttt{.bil}	& Band-interleaved raw data files.\\\hline
\end{tabular}
\end{center}


\end{table}

Some of these data formats can also be stored in gzipped form, i.e \texttt{.hgt.gz} or \texttt{.dem.gz}.

### Projections

Some of the file formats have their projection data given in the data file. However, some of the file formats contain no projection information, so this must be specified in the data block. GeoGFX supports all projections and datums supported by the PROJ4 projection package (\texttt{http://proj.maptools.org/}). For example, an ASCIIGRID input file in UTM Zone 33 projection, WGS84 datum must be specified like this:

input_dir {
path   = /data/geodata/Norge/dted100m
ext    = .asc
coosys = +proj=utm +zone=33 +datum=WGS84
}


Unprojected data (geographical lat/lon coordinates) in WGS84 datum need no projection information.

## Terrain generator parameters

The last section is where you set the input for the terrain surface generator. The only parameter here at the moment is the \texttt{tolerance} parameter. This is the maximum allowed vertical distance between the generated terrain model and the original data. I.e if you select 1.5m here, the maximum error in the surface will be 1.5 meters relative to the input data set. The lower this tolerance is, the larger the terrain file will be. It's usually wise to set this at a number between 1 and 5 meters to keep file size down, while still retaining good accuracy.