Heightfield 1.0
|
A simple height field. More...
#include <heightfield.h>
Public Member Functions | |
HeightField () | |
Empty. | |
HeightField (const ScalarField2 &) | |
Create a heightfield from a scalar field. More... | |
HeightField (const Box2 &, const QImage &, const double &=0.0, const double &=256.0 *256.0 - 1.0, bool=true) | |
Create a heightfield from an image. More... | |
HeightField (const Box2 &, int, int, const double &=0.0) | |
Create a flat heightfield. More... | |
HeightField (const Box2 &, int, int, const QVector< double > &) | |
Create a heightfield. More... | |
~HeightField () | |
Empty. | |
double | GetHeight (const Vector2 &) const |
Compute the height at a given position. More... | |
Vector | Vertex (const Vector2 &, bool=true) const |
Compute the vertex position on the terrain. More... | |
Vector | Vertex (int, int) const |
Compute the vertex corresponding to a given sample. More... | |
QVector< Vector > | ArrayVertexes (const QVector< QPoint > &) const |
Compute the coordinates of a set of points on the grid. More... | |
Vector | Normal (const Vector2 &, bool=true) const |
Compute the normal for a given position on the terrain. More... | |
Vector | Normal (int, int) const |
Compute the normal at a given sample. More... | |
double | Slope (int, int) const |
Compute the slope at a given integer point on the terrain. More... | |
double | Slope (const QPoint &, const QPoint &) const |
Compute the slope between two points. More... | |
double | AverageSlope (int, int) const |
Compute the average slope at a given integer point on the terrain. More... | |
double | Aspect (int, int) const |
Compute the aspect (face orientation) at a given integer point on the terrain. More... | |
double | K () const |
Compute the Lipschitz constant of the signed distance field defined as f(x,y,z)=z-h(x,y). | |
void | Subdivide (const double &, Random &=Random::R239) |
Refine the terrain. More... | |
ScalarField2 | StreamArea () const |
Compute the stream area field of the terrain. More... | |
ScalarField2 | StreamAreaWeighted (const double &=2.0) const |
Compute the stream area field of the terrain. More... | |
ScalarField2 | StreamAreaSteepest () const |
Compute the stream area field of the terrain. More... | |
ScalarField2 | StreamAreaLimited (const double &) const |
Compute the stream area field of the terrain using a limited flow propagation. More... | |
ScalarField2 | StreamLength (bool=false) const |
Compute the stream length. More... | |
ScalarField2 | StreamSourceElev (bool=false) const |
Return the maximum source elevation of the flows converging to each point in the height field. More... | |
VectorField2 | FlowField (ScalarField2 &) const |
Compute the flow field of the terrain. More... | |
ScalarField2 | AverageSlope () const |
Compute the average slope field of the terrain. | |
ScalarField2 | Slope (bool=false) const |
Compute the maximum slope field of the terrain. More... | |
ScalarField2 | Aspect () const |
Compute the aspect field (face orientation) of the terrain. | |
ScalarField2 | WetnessIndex (const double &=1.0e-3, bool=false) const |
Compute the wetness index field of the terrain. More... | |
ScalarField2 | StreamPower (bool=false) const |
Compute the stream power field of the terrain. More... | |
ScalarField2 | StreamPower (double, double) const |
Compute the stream power field of the terrain. More... | |
ScalarField2 | ReliefSteepness (const double &) const |
Compute the omni-directional relief and steepness. More... | |
ScalarField2 | Peakedness (const double &) const |
Compute the peakedness of a terrain, defined as the percentage of cells in a disk that have lower or equal elevation than the center position. More... | |
ScalarField2 | TopographicPositionIndex (const double &r) const |
Compute the TPI, an index that measures how much a cell rises with respect to the mean elevation of a given radius. It is very similar in spirit to Peakedness, but here we obtain a value in m instead of the % of cells below it. More... | |
ScalarField2 | LocalVariance (int=3) const |
Compute the local variance. More... | |
ScalarField2 | SurfaceRoughness (int=3) const |
Compute the surface roughness. More... | |
ScalarField2 | HillslopeAsymmetry (double, double=0, double=45) const |
Compute the hillslope asymmetry map for a given direction. More... | |
ScalarField2 | Accessibility (const double &, int=16) const |
Compute the accessibility. More... | |
ScalarField2 | Light (const Vector &, bool=false) const |
Compute the direct lighting. More... | |
int | FillDepressions () |
Fills all pits and removes all digital dams from the HeightField. More... | |
int | FillDepressions (const double &) |
Modifies the HeightField to guarantee drainage. More... | |
int | FillDepressions (ScalarField2 &) const |
Fills all pits and removes all digital dams from the HeightField. More... | |
int | FillDepressions (const double &, ScalarField2 &) const |
Modifies the HeightField to guarantee drainage. More... | |
void | CompleteBreach () |
Breach depressions. More... | |
bool | Intersect (const Ray &, double &, Vector &, const Box &, const double &, const double &=1.0e8, const double &=1.0e-4) const |
Compute the intersection between a ray and the surface of the heightfield. More... | |
bool | Intersect (const Ray &, QVector< double > &, QVector< Vector > &, const Box &, const double &) const |
Compute the intersection between a ray and the surface of the heightfield. More... | |
bool | IntersectBox (const Ray &, double &, Vector &, Vector &, const Box &) const |
Compute the intersection between a ray and the surface border of the heightfield. More... | |
double | Shade (const Vector &, const QVector< Vector > &, const QVector< double > &, const double &) const |
Shade a vector of the terrain. More... | |
ScalarField2 | Sun (const double &, int=5, int=1, int=0, int=12) const |
Compute the average direct lighting from the sun over a year. More... | |
ScalarField2 | SelfShadow (const Vector &) const |
Compute the self shadowing map. More... | |
ArrayInteger2 | Flow (bool=false) const |
Compute the flow topology. More... | |
ArrayInteger2 | Geomorphons (const double &=0.02) const |
Compute the geomorphon index map. More... | |
ArrayInteger2 | GeomorphonsTangent (double, double=0.02) const |
Compute the geomorphon index map. More... | |
ArrayInteger2 | GeomorphonsAggregated (const double &=0.02) const |
Compute the aggregated geomorphon index map. More... | |
Box | GetBox () const |
Get the bounding box of the heightfield. More... | |
double | Signed (const Vector &) const |
Compute the signed distance do the heightfield. More... | |
void | Scale (const Vector &) |
Scale the height field. More... | |
void | Unity () |
Scale the heightfield so that the compact support should fit within unit box. More... | |
void | Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const |
Draw a heightfield. More... | |
QVector< QPoint > | Up (int, int) const |
Compute the cells that are uphill of input point. More... | |
QVector< QPoint > | Down (int, int) const |
Compute the cells that are downhill of input point. More... | |
int | CheckFlowSlope (const QPoint &, FlowStruct &) const |
Compute the flow directions at a given point. More... | |
int | CheckFlowSlopeWeighted (const QPoint &, FlowStruct &, const double &=2.0) const |
Compute the flow directions at a given point, using an L2 metric. More... | |
int | CheckFlowDirectionsAngle (const QPoint &, const double &, FlowStruct &) const |
Compute the flow directions at a given point. More... | |
Mesh | CreateMesh (bool=true, bool=false, const double &=0.0) const |
Create the geometry of the heightfield. More... | |
Mesh | CreateMeshSide (const double &=0.0) const |
Create the geometry of the border of the terrain. More... | |
void | CreateCubes (Box &, QVector< FrameScaled > &, const double &=-10.0) const |
Create a stack representation of the model. More... | |
void | Carve (const CubicCurve &, const double &, const double &) |
Carve the terrain using a cubic curve, whose elevation define the prescribed elevation along the curve. More... | |
void | Carve (const QuadricCurve &, const double &, const double &) |
Carve the terrain using a quadric curve, whose elevation define the prescribed elevation along the curve. More... | |
void | Carve (const CubicCurveSet &, const double &, const double &) |
Carve the terrain using a piecewise cubic curve, whose elevation define the prescribed elevation along the curve. More... | |
void | Carve (const QuadricCurveSet &, const double &, const double &) |
Carve the terrain using a piecewise quadric curve, whose elevation define the prescribed elevation along the curve. More... | |
void | Carve (const Segment &, const double &, const double &) |
Carve the terrain using a segment, whose elevation define the prescribed elevation along the curve. More... | |
void | Carve (const SmoothDisc2 &, const double &) |
Flatten the scalar field. More... | |
ScalarField2 | GradientDistance (const HeightField &) const |
Compute the gradient distance between two heightfields. More... | |
ScalarField2 | Sea (const double &=0.0) const |
Compute the water elevation in every cell according to a uniform sea level. More... | |
QVector< double > | Cross (const Vector2 &, const Vector2 &, int) const |
Compute the elevation along a segment. More... | |
void | SmoothBreachMultiScale (const QVector< double > &) |
Smooth breaching with a given input series. More... | |
void | SmoothBreachGeometric (double, double) |
Smooth breaching with a geometric series. More... | |
void | SmoothBreachLinear (double) |
Smooth breaching process. More... | |
Static Public Attributes | |
static const double | flat = 1.0e-8 |
Small negative epsilon value used in breaching and flow algorithms. | |
A simple height field.
HeightField::HeightField | ( | const ScalarField2 & | s | ) |
Create a heightfield from a scalar field.
This constructor provides implicit conversion.
s | Scalar field. |
|
explicit |
Create a heightfield from an image.
box | Rectangle domain of the terrain. |
image | Elevation image. |
a,b | Minimum and maximum elevation range. |
grayscale | Boolean set to false if the image is provided in color. |
|
explicit |
Create a flat heightfield.
box | Rectangle domain of the terrain. |
nx,ny | Samples. |
v | Constant elevation. |
|
explicit |
Create a heightfield.
box | Rectangle domain of the terrain. |
nx,ny | Samples. |
v | Set of elevation values. |
ScalarField2 HeightField::Accessibility | ( | const double & | r, |
int | n = 16 |
||
) | const |
Compute the accessibility.
r | Radius. |
n | Number of rays. |
QVector< Vector > HeightField::ArrayVertexes | ( | const QVector< QPoint > & | p | ) | const |
Compute the coordinates of a set of points on the grid.
p | Set of point. |
double HeightField::Aspect | ( | int | i, |
int | j | ||
) | const |
Compute the aspect (face orientation) at a given integer point on the terrain.
i,j | Integer coordinates |
double HeightField::AverageSlope | ( | int | i, |
int | j | ||
) | const |
Compute the average slope at a given integer point on the terrain.
Simply average the slope in 8 directions.
i,j | Integer coordinates |
void HeightField::Carve | ( | const CubicCurve & | c, |
const double & | r, | ||
const double & | b | ||
) |
Carve the terrain using a cubic curve, whose elevation define the prescribed elevation along the curve.
c | Curve. |
r | Radius. |
b | Blending radius. |
void HeightField::Carve | ( | const CubicCurveSet & | c, |
const double & | r, | ||
const double & | b | ||
) |
Carve the terrain using a piecewise cubic curve, whose elevation define the prescribed elevation along the curve.
c | Curve. |
r | Radius. |
b | Blending radius. |
void HeightField::Carve | ( | const QuadricCurve & | c, |
const double & | r, | ||
const double & | b | ||
) |
Carve the terrain using a quadric curve, whose elevation define the prescribed elevation along the curve.
c | Curve. |
r | Radius. |
b | Blending radius. |
void HeightField::Carve | ( | const QuadricCurveSet & | c, |
const double & | r, | ||
const double & | b | ||
) |
Carve the terrain using a piecewise quadric curve, whose elevation define the prescribed elevation along the curve.
c | Curve. |
r | Radius. |
b | Blending radius. |
void HeightField::Carve | ( | const Segment & | c, |
const double & | r, | ||
const double & | b | ||
) |
Carve the terrain using a segment, whose elevation define the prescribed elevation along the curve.
s | Segment. |
r | Radius. |
b | Blending radius. |
void HeightField::Carve | ( | const SmoothDisc2 & | disc, |
const double & | e | ||
) |
Flatten the scalar field.
disc | Smooth disc reion. |
e | Target elevation. |
int HeightField::CheckFlowDirectionsAngle | ( | const QPoint & | p, |
const double & | s, | ||
FlowStruct & | flow | ||
) | const |
Compute the flow directions at a given point.
p | Point. |
s | Slope. |
flow | Flow information. |
int HeightField::CheckFlowSlope | ( | const QPoint & | p, |
FlowStruct & | flow | ||
) | const |
Compute the flow directions at a given point.
Compute both the flow directions using an Lp metric, and the steepest slope.
p | Point. |
flow | Flow information. |
int HeightField::CheckFlowSlopeWeighted | ( | const QPoint & | p, |
FlowStruct & | flow, | ||
const double & | power = 2.0 |
||
) | const |
Compute the flow directions at a given point, using an L2 metric.
p | Point. |
flow | Flow information. |
power | Power, set to 1.0 for diffusive flow routing, converges to steepest slope as power increases to infinity. |
void HeightField::CompleteBreach | ( | ) |
Breach depressions.
Depression breaching drills a path from a depression's pit cell (its lowest point) along the least-cost (Priority-Flood) path to the nearest cell outside the depression to have the same or lower elevation.
See https://github.com/r-barnes/richdem
See https://github.com/r-barnes/richdem/blob/master/include/richdem/depressions/Lindsay2016.hpp
void HeightField::CreateCubes | ( | Box & | cube, |
QVector< FrameScaled > & | frames, | ||
const double & | z = -10.0 |
||
) | const |
Create a stack representation of the model.
Stacks are defined as scaled boxes.
cube | Reference cube. |
frames | Set of instances. |
z | Base elevation. |
Mesh HeightField::CreateMesh | ( | bool | surface = true , |
bool | side = false , |
||
const double & | z = 0.0 |
||
) | const |
Create the geometry of the heightfield.
surface | Generate the surface elevation of the heightfield. |
side | Generate the side of the heightfield. |
z | The height of the base of the block. |
Mesh HeightField::CreateMeshSide | ( | const double & | z = 0.0 | ) | const |
Create the geometry of the border of the terrain.
z | The height of the base of the block. |
Compute the elevation along a segment.
a,b | Segment. |
n | Number of samples. |
QVector< QPoint > HeightField::Down | ( | int | x, |
int | y | ||
) | const |
Compute the cells that are downhill of input point.
x,y | Integer coordinates of the point. |
void HeightField::Draw | ( | QGraphicsScene & | scene, |
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) | const |
Draw a heightfield.
scene | Graphics scene. |
pen | The pen. |
brush | The brush. |
int HeightField::FillDepressions | ( | ) |
Fills all pits and removes all digital dams from the HeightField.
int HeightField::FillDepressions | ( | const double & | eps | ) |
Modifies the HeightField to guarantee drainage.
eps | The minimal elevation difference between two cells. |
int HeightField::FillDepressions | ( | const double & | eps, |
ScalarField2 & | depression_field | ||
) | const |
Modifies the HeightField to guarantee drainage.
Algorithm: Priority-flood: An optimal depression-filling and watershed-labeling algorithm for digital elevation models. Barnes, R., Lehman, C., Mulla, D., 2014.
This version of Priority-Flood starts on the edges of the DEM and then works its way inwards using a priority queue to determine the lowest cell which has a path to the edge. The neighbours of this cell are added to the priority queue if they are higher. If they are lower, then their elevation is increased by a small amount to ensure that they have a drainage path and they are added to a "pit" queue which is used to flood pits. Cells which are higher than a pit being filled are added to the priority queue. In this way, pits are filled without incurring the expense of the priority queue.
The values to fill the depressions are added to the depression field.
The depression field should have the exact same size as the HeightField. If the given depression field does not have the exact same size as the height field, returns the total number of vertices in the heightfield.
To be sure that the height field is never flat, elevations are always increased by std::nextafter(elevation) + eps. Thus, even if eps == 0, the terrain is never flat.
Warning, because the method is const it is not recommended to use it like that
eps | The minimal elevation difference between two cells. |
depression_field | A scalar field in which the values to fill depressions are added |
int HeightField::FillDepressions | ( | ScalarField2 & | d | ) | const |
Fills all pits and removes all digital dams from the HeightField.
Algorithm: Priority-flood: An optimal depression-filling and watershed-labeling algorithm for digital elevation models. Barnes, R., Lehman, C., Mulla, D., 2014.
Priority-Flood starts on the edges of the DEM and then works its way inwards using a priority queue to determine the lowest cell which has a path to the edge. The neighbours of this cell are added to the priority queue if they are higher. If they are lower, they are raised to the elevation of the cell adding them, thereby filling in pits. The neighbors are then added to a "pit" queue which is used to flood pits. Cells which are higher than a pit being filled are added to the priority queue. In this way, pits are filled without incurring the expense of the priority queue.
The values to fill the depressions are added to the depression field.
The depression field should have the exact same size as the HeightField. If the given depression field does not have the exact same size as the height field, returns the total number of vertices in the heightfield.
Warning, because the method is const it is not recommended to use it like that
d | A scalar field in which the values to fill depressions are added |
ArrayInteger2 HeightField::Flow | ( | bool | steep = false | ) | const |
Compute the flow topology.
steep | Flag, set to true if we rely on the steepest slope, false for multiple convergent and divergent flows. |
VectorField2 HeightField::FlowField | ( | ScalarField2 & | stream | ) | const |
Compute the flow field of the terrain.
The direction if the average downhill flow.
This function differs slightly from HeightField::StreamArea(). Pits have a null flow vector, although the stream area is a local maximum.
The stream area is computed as a fraction of cells, independtly of the surface area of a cell.
stream | Returned stream area; |
ArrayInteger2 HeightField::Geomorphons | ( | const double & | t = 0.02 | ) | const |
Compute the geomorphon index map.
Geomorphon classify cells into ten categories: flat, peak, ridge, shoulder, hollow, slope, spur, footslope, valley, and pit.
t | Slope threshold. |
ArrayInteger2 HeightField::GeomorphonsAggregated | ( | const double & | t = 0.02 | ) | const |
Compute the aggregated geomorphon index map.
Aggregation classifies into only five categories: flat (flat), ridges (ridge, peak, spur, shoulder), slope (slope), valley (valley, pit, hollow) and foot slope (foot slope).
t | Slope threshold. |
ArrayInteger2 HeightField::GeomorphonsTangent | ( | double | maxDist, |
double | flatTangent = 0.02 |
||
) | const |
Compute the geomorphon index map.
Geomorphon classify cells into ten categories: flat, peak, ridge, shoulder, hollow, slope, spur, footslope, valley, and pit.
maxDist | maximum ray traversal distance. |
flatTangent | threshold for considering a ray angle as flat. |
Box HeightField::GetBox | ( | ) | const |
Get the bounding box of the heightfield.
Note that although this function has the same name as Array2::GetBox(), it computes the minimum and maximum elevation of the terrain (computationally intensive).
|
inline |
Compute the height at a given position.
p | Point. |
ScalarField2 HeightField::GradientDistance | ( | const HeightField & | h | ) | const |
Compute the gradient distance between two heightfields.
h | Second heightfield. |
ScalarField2 HeightField::HillslopeAsymmetry | ( | double | km, |
double | direction = 0 , |
||
double | tolerance = 45 |
||
) | const |
Compute the hillslope asymmetry map for a given direction.
Poulos et al 2012. Hillslope asymmetry maps reveal widespread, multi-scale organization
The authors define hillsope asymmetry as the difference in median slope between slopes of opposite orientation inside an area.
NOTE: I used average slopes instead of median. First, for a reason of efficiency. Second, it also makes more sense in my opinion. In any case, results visually very similar. It is possible to change the behavior in the code, just set MEDIAN_ASYMMETRY = true
km | Side length of area in which analysis is performed. |
Direction | angle (in degrees, 0 is +X). |
Tolerance | how much we can deviate from this angle. |
bool HeightField::Intersect | ( | const Ray & | ray, |
double & | t, | ||
Vector & | q, | ||
const Box & | box, | ||
const double & | k, | ||
const double & | length = 1.0e8 , |
||
const double & | epsilon = 1.0e-4 |
||
) | const |
Compute the intersection between a ray and the surface of the heightfield.
The algorithm uses a ray marching approach, therefore this function may require many iterations and the resulting intersection may not be accurate.
ray | The ray. |
t | Returned distance along the ray. |
box | Box where intersection will be computed. |
q | Returned intersection point. |
k | Lipschitz constant. |
length | Maximum distance along the ray. |
epsilon | Minimum stepping distance. |
bool HeightField::Intersect | ( | const Ray & | ray, |
QVector< double > & | tv, | ||
QVector< Vector > & | q, | ||
const Box & | box, | ||
const double & | k | ||
) | const |
Compute the intersection between a ray and the surface of the heightfield.
The algorithm uses a sphere tracing approach, therefore this function may require many iterations and the resulting intersection may not be accurate.
ray | The ray. |
tv | Returned distance along the ray. |
box | Box where intersection will be computed. |
q | Returned intersection point. |
k | Lipschitz constant. |
bool HeightField::IntersectBox | ( | const Ray & | ray, |
double & | t, | ||
Vector & | p, | ||
Vector & | n, | ||
const Box & | box | ||
) | const |
Compute the intersection between a ray and the surface border of the heightfield.
ray | The ray. |
t | Distance along the ray. |
box | Box where intersection will be computed. |
p | Returned intersection point. |
n | Returned normal. |
ScalarField2 HeightField::Light | ( | const Vector & | u, |
bool | cosine = false |
||
) | const |
Compute the direct lighting.
u | Light direction. |
cosine | Boolean, set to true to use scalar product between normal and light, false to use (1+c)/2. |
ScalarField2 HeightField::LocalVariance | ( | int | w = 3 | ) | const |
Compute the local variance.
Woodcock and Strahler 1987. The factor of scale in remote sensing. Dragut et al. 2011. Local variance for multi-scale analysis in geomorphometry.
Local variance is defined as the standard deviation of a window centered around the cell.
Compute the local variance of every cell and take the average over all the domain.
Authors plot the mean local variance with respect to image scale, and show that peaks in this graph occur at 1/2 to 3/4 the size of objects in the image, so it could be used as a scale indicator.
w | Window size (authors recommend 3). |
Compute the normal for a given position on the terrain.
Note that this function may be expensive to compute.
p | Point. |
triangular | Boolean, use triangle normals if set to true, bilinear interpolation of normals at vertices otherwize. |
Vector HeightField::Normal | ( | int | i, |
int | j | ||
) | const |
Compute the normal at a given sample.
This function uses the weighted sum (area) of the normals of the triangles sharing the point on the grid. The returned vector is normalized.
i,j | Integer coordinates of the sample. |
ScalarField2 HeightField::Peakedness | ( | const double & | r | ) | const |
Compute the peakedness of a terrain, defined as the percentage of cells in a disk that have lower or equal elevation than the center position.
See Llobera 2001, Building Past Landscape Perception With GIS: Understanding Topographic Prominence. Although the author calls it prominence, it is not the same definition as used in orometry for peak prominence.
See Arge et al. 2013: Algorithms for Computing Prominence on Grid Terrains for faster implementations.
r | Radius of the disk (we actually use a squared window). |
ScalarField2 HeightField::ReliefSteepness | ( | const double & | r | ) | const |
Compute the omni-directional relief and steepness.
See Earl and Metzler 2015, Cloud-Capped Towers: Capturing Terrain Characteristics Using Topographic Functionals.
From a theoretical point of view, ORS is the value that results from convergence when we integrate all distances. ORS monotonically increases as we make this cut-off bigger, since the function we integrate is always positive. From my experience (and by definition) after only a few km of distance 10-20, the value is already a good approximation but also, different radius cut-off highlight different interesting properties. If we use a small radius, those points with a very steep edge nearby or even needle-shaped secondary small peaks will have large values of ORS, more than other bigger but gentler peaks. When the radius increases, bigger peaks shadow them with larger ORS values.
r | Radius for cutting the computation at some point. |
void HeightField::Scale | ( | const Vector & | s | ) |
Scale the height field.
The domain is scaled using the x and y components of the scaling vector, whereas the heights of the heightfield are scaled using the z component.
s | Scaling factor. |
ScalarField2 HeightField::Sea | ( | const double & | height = 0.0 | ) | const |
Compute the water elevation in every cell according to a uniform sea level.
ScalarField2 HeightField::SelfShadow | ( | const Vector & | light | ) | const |
Compute the self shadowing map.
light | Light direction. |
double HeightField::Shade | ( | const Vector & | p, |
const QVector< Vector > & | lights, | ||
const QVector< double > & | intensity, | ||
const double & | sum | ||
) | const |
Shade a vector of the terrain.
p | Terrain coordinates. |
lights | Set of lights. |
intensity | Set of light intensities. |
sum | Sum. |
double HeightField::Signed | ( | const Vector & | p | ) | const |
Compute the signed distance do the heightfield.
This function uses ScalarField2::BiCubicValue to compute the elevation.
The volume delimited by the heightfield is embedded an infinite vertical box.
p | Point. |
ScalarField2 HeightField::Slope | ( | bool | a = false | ) | const |
Compute the maximum slope field of the terrain.
Simply compute the norm of the gradient.
This function may be used to perform hill-slope erosion simulation.
a | Boolean, use average slope if set to true, and slope otherwize. |
double HeightField::Slope | ( | const QPoint & | pa, |
const QPoint & | pb | ||
) | const |
Compute the slope between two points.
pa,pb | Points. |
double HeightField::Slope | ( | int | i, |
int | j | ||
) | const |
Compute the slope at a given integer point on the terrain.
This is a convenience function corresponding to the following piece of code:
i,j | Integer coordinates |
void HeightField::SmoothBreachGeometric | ( | double | r, |
double | a | ||
) |
Smooth breaching with a geometric series.
r | Radius, breaching will be performed at the corresponding resolution. |
a | Attenuation. |
void HeightField::SmoothBreachLinear | ( | double | r | ) |
Smooth breaching process.
r | Radius, breaching will be performed at the corresponding resolution with linear attenuation. |
void HeightField::SmoothBreachMultiScale | ( | const QVector< double > & | ri | ) |
Smooth breaching with a given input series.
ri | Set of radii, breaching will be performed at the corresponding resolutions. |
ScalarField2 HeightField::StreamArea | ( | ) | const |
Compute the stream area field of the terrain.
The stream area is computed as a fraction of cells, independtly of the surface area of a cell.
ScalarField2 HeightField::StreamAreaLimited | ( | const double & | r | ) | const |
Compute the stream area field of the terrain using a limited flow propagation.
r | Flow propagation range, this function is the same as HeightField::StreamArea() if range is infinitely large. |
ScalarField2 HeightField::StreamAreaSteepest | ( | ) | const |
Compute the stream area field of the terrain.
ScalarField2 HeightField::StreamAreaWeighted | ( | const double & | power = 2.0 | ) | const |
Compute the stream area field of the terrain.
The stream area is computed as a fraction of cells, independtly of the surface area of a cell.
power | Power. |
ScalarField2 HeightField::StreamLength | ( | bool | steepest = false | ) | const |
Compute the stream length.
The stream length is computed, for all cells, as the maximum distance to a spring, which are the peaks.
ScalarField2 HeightField::StreamPower | ( | bool | a = false | ) | const |
Compute the stream power field of the terrain.
The algorithm works as follows: first compute the stream area for every terrain sample, and then compute the stream power index.
a | Boolean, use average slope if set to true, and slope otherwize. |
ScalarField2 HeightField::StreamPower | ( | double | m, |
double | n | ||
) | const |
Compute the stream power field of the terrain.
The algorithm works as follows: first compute the stream area for every terrain sample, and then compute the stream power index.
m,n | Exponent for the stream area and slope, n should be twice as m. |
ScalarField2 HeightField::StreamSourceElev | ( | bool | steepest = false | ) | const |
Return the maximum source elevation of the flows converging to each point in the height field.
steepest | If true, uses D8 routing algorithm. Otherwise, MFD |
void HeightField::Subdivide | ( | const double & | e, |
Random & | r = Random::R239 |
||
) |
Refine the terrain.
This function subdivides the samples and uses a smooth interpolation. A random elevation may be added to the samples.
e | Amplitude of the random elevation added to the samples. |
r | Random number generator. |
ScalarField2 HeightField::Sun | ( | const double & | latitude, |
int | daystep = 5 , |
||
int | hourstep = 1 , |
||
int | dayoffset = 0 , |
||
int | houroffset = 12 |
||
) | const |
Compute the average direct lighting from the sun over a year.
latitude | Latitude of the terrain, longitude is set to 0.0. |
ScalarField2 HeightField::SurfaceRoughness | ( | int | w = 3 | ) | const |
Compute the surface roughness.
Lindsay et al 2019. Scale-optimized surface roughness for topographic analysis.
The authors associate surface normals dispersion to roughness, a measure of texture complexity. In particular, they measure the spherical standard deviation in a window w × w, i.e. the angular spread of the normal directions in the window. It will be 0 for flat and inclined planes, and increase with surface texture complexity.
They also propose to remove lower frequencies by doing a gaussian low-pass filter on the DEM, to obtain a signature that depends only on current scale (otherwise, it increases monotonically with w).
w | Window size. |
ScalarField2 HeightField::TopographicPositionIndex | ( | const double & | r | ) | const |
Compute the TPI, an index that measures how much a cell rises with respect to the mean elevation of a given radius. It is very similar in spirit to Peakedness, but here we obtain a value in m instead of the % of cells below it.
This function is widely used (or was) to classify landforms, and it is integrated in many GIS packages.
See Weiss 2001: Topographic position and landforms analysis (poster) And Wilson and Gallant 2000: Primary Topographic Attributes (chapter 3 in "Terrain Analysis: Principles and Applications")
r | Radius of the disk (we actually use a squared window). |
void HeightField::Unity | ( | ) |
Scale the heightfield so that the compact support should fit within unit box.
Centers the terrain and scales it.
QVector< QPoint > HeightField::Up | ( | int | x, |
int | y | ||
) | const |
Compute the cells that are uphill of input point.
x,y | Integer coordinates of the point. |
Compute the vertex position on the terrain.
p | Point. |
triangular | Boolean, use triangular interpolation if set to true, bilinear interpolation otherwize. |
Vector HeightField::Vertex | ( | int | i, |
int | j | ||
) | const |
Compute the vertex corresponding to a given sample.
i,j | Integer coordinates of the sample. |
ScalarField2 HeightField::WetnessIndex | ( | const double & | c = 1.0e-3 , |
bool | a = false |
||
) | const |
Compute the wetness index field of the terrain.
The algorithm works as follows: first compute the stream area for every terrain sample, and then compute the wetness index.
Note that the wetness index is defined as ln ( A / s ) where s is the slope, however the definition does not work well for small slopes, therefore the implementation defines the wetness index as ln ( A / ( e + s ) ), where e is 0.001.
c | Coefficent for slope factor, if set to 0 the function will compute the logarithm of the drainage area. |
a | Boolean, use average slope if set to true, and slope otherwize. |