Difference between revisions of "Howto:Adding Cliffs To Terrain"

From FlightGear wiki
Jump to navigation Jump to search
(Switched "(Under construction)" to the {{WIP}} template.)
Line 1: Line 1:
(Under construction)
==Why do cliffs require special treatment?==
==Why do cliffs require special treatment?==

Revision as of 05:16, 19 April 2019

WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.

Why do cliffs require special treatment?

Terrain generated from elevation data on a grid (e.g. Shuttle mission SRTM data) will tend to smooth out abrupt changes in height, such as cliffs. This is because each point on the grid records the average height in the region of the point, and TerraGear will, by default, smoothly interpolate between these points. So even if the grid elevation points were true point heights, the change in elevation is spread over the distance to the next grid point and cliffs become steep (or not-so-steep) slopes. The procedure below describes how to avoid these smoothing effects and properly texture the resulting near-vertical surfaces.

The following instructions assume that you are familiar with the TerraGear toolchain, extracting data from OpenStreetMaps, and creating shapefiles. In the commands below, <scenery_top> refers to a directory with a conventional layout for scenery construction, that is, containing shapefile and height data in data, intermediate files in work, and output in output. Other files are placed in scenery_top/rawdata


The procedure below assumes that you have already prepared elevation data as described in Using TerraGear.

Step 1: extract cliff data

OpenStreetMaps records the location of cliffs by attaching the tag "natural=cliff" to line features. Extract these features into a shapefile. The example below uses osmosis to extract data from an OSM pbf file covering Australia into OSM XML file cliffs.osm, which is then converted to shapefile cs_cliffs using ogr2ogr:

osmosis --read-pbf <scenery_top>/rawdata/australia-latest.osm.pbf --bounding-box top=-31 bottom=-36 left=114 right=119 completeWays=yes --lp --tf accept-ways '
natural=cliff' --tf reject-relations --used-node --write-xml file='<scenery_top>/rawdata/cliffs.osm'
ogr2ogr -where "OGR_GEOMETRY='LineString'" -f 'ESRI shapefile' -lco SHPT=ARC <scenery_top>/data/cs_cliffs <scenery_top>/rawdata/cliffs.osm

Fixing the topography

Step 2: add cliff data to height data

Tool cliff-decode distributed with TerraGear (version "next" as of early 2019) takes a cliff shapefile for an area and divides it up amongst the height tiles ("buckets") that make up that area, so that elevation calculations can use these cliff lines as known discontinuities in the topography. The first argument is the location of the directory tree containing height files, and the second is the shapefile generated in the previous step:

cliff-decode <scenery_top>/work/SRTM-3 <scenery_top>/data/cs_cliffs

The example command places multiple files with extension cliff in each of the area "buckets" underneath the SRTM-3 directory, if any cliffs are present, of course! TerraGear (version 2019.1 "next") will not interpolate elevations across any of these cliff lines when constructing terrain.

Step 3: rectify heights (optional but desirable)

The rectify_height tool supplied with Terragear (version "next" as of early 2019) uses any cliff files found in the elevation directories to improve the elevation information. The argument --min-dist specifies how far away from a cliff a point must be in order for its height to be trustworthy. Any points closer than this distance will be interpolated from the trustworthy points. If no trustworthy points can be found (for example, the top of a small butte), the elevations are not changed. A suitable value should be at least 1 elevation grid spacing.

rectify_height --work-dir=<scenery_top>/work/ --height-dir=SRTM-3 --min-lon=151.0 --max-lon=152.0 --min-lat=-34.0 --max-lat=-33.0 --min-dist=100

After running this command a series of files with extension rectified will be found in the height subdirectories. TerraGear will preferentially use these files when interpolating elevations, as well as not interpolating across cliff lines. If you skip the rectification step, TerraGear with rectify on the fly for every point, potentially duplicating rectification calculations for the same group of points many times.