Howto:Adding Cliffs To Terrain: Difference between revisions
JamesHester (talk | contribs) No edit summary |
JamesHester (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
==Why do cliffs require special treatment?== | ==Why do cliffs require special treatment?== | ||
Terrain generated from | 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, <code><scenery_top></code> refers to a directory with a conventional layout for scenery construction, that is, containing shapefile and height data in <code>data</code>, intermediate files in <code>work</code>, and output in <code>output</code>. Other files are placed in <code>scenery_top/rawdata</code> | The following instructions assume that you are familiar with the [[TerraGear]] toolchain, extracting data from OpenStreetMaps, and creating shapefiles. In the commands below, <code><scenery_top></code> refers to a directory with a conventional layout for scenery construction, that is, containing shapefile and height data in <code>data</code>, intermediate files in <code>work</code>, and output in <code>output</code>. Other files are placed in <code>scenery_top/rawdata</code> | ||
==Preparation== | ==Preparation== | ||
The procedure below assumes that you have already prepared elevation data as described in [[Using TerraGear]]. | |||
===Step 1: extract cliff data=== | ===Step 1: extract cliff data=== | ||
OpenStreetMaps records the location of cliffs by attaching the tag <code>"natural=cliff"</code> 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 file <code>cliffs.osm</code>, which is then converted to shapefile <code>cs_cliffs</code> using ogr2ogr: | OpenStreetMaps records the location of cliffs by attaching the tag <code>"natural=cliff"</code> 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 <code>cliffs.osm</code>, which is then converted to shapefile <code>cs_cliffs</code> 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 ' | 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 ' | ||
Line 19: | Line 22: | ||
===Step 2: add cliff data to height data=== | ===Step 2: add cliff data to height data=== | ||
Tool <code>cliff-decode</code> 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 | Tool <code>cliff-decode</code> 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 | cliff-decode <scenery_top>/work/SRTM-3 <scenery_top>/data/cs_cliffs | ||
The example command places multiple files with extension <code>cliff</code> in each of the area "buckets" underneath the <code>SRTM-3</code> directory, if any cliffs are present, of course! | The example command places multiple files with extension <code>cliff</code> in each of the area "buckets" underneath the <code>SRTM-3</code> 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=== | ===Step 3: rectify heights (optional but desirable)=== | ||
The <code>rectify_height</code> tool supplied with Terragear (version "next" as of early 2019) uses any <code>cliff</code> files found in the | The <code>rectify_height</code> tool supplied with Terragear (version "next" as of early 2019) uses any <code>cliff</code> files found in the elevation directories to improve the elevation information. The argument <code>--min-dist</code> 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 | 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 <code>rectified</code> will be found in the height subdirectories. TerraGear will preferentially use these files when interpolating | After running this command a series of files with extension <code>rectified</code> will be found in the height subdirectories. TerraGear will preferentially use these files when interpolating elevations, | ||
as well as | 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. |
Revision as of 05:10, 19 April 2019
(Under construction)
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
Preparation
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.