iLand
Public Member Functions | List of all members
DEM Class Reference

DEM is a digital elevation model class. More...

#include <dem.h>

Inheritance diagram for DEM:
Grid< float >

Public Member Functions

 DEM (const QString &fileName)
 
bool loadFromFile (const QString &fileName)
 loads a DEM from a ESRI style text file. More...
 
void createSlopeGrid () const
 
const FloatGridaspectGrid () const
 
const FloatGridslopeGrid () const
 
const FloatGridviewGrid () const
 
float elevation (const float x, const float y) const
 get the elevation (m) at point (x/y) More...
 
float elevation (const QPointF p) const
 
float direction (const float x, const float y)
 get the direction of the slope at point (x/y) if the slope at the point is 0, "north" (0) is returned. More...
 
float slope (const float x, const float y)
 
float orientation (const QPointF &point, float &rslope_angle, float &rslope_aspect) const
 get orientation at specific point (x,y) and height More...
 
float orientation (const float x, const float y, float &rslope_angle, float &rslope_aspect)
 
- Public Member Functions inherited from Grid< float >
 Grid ()
 
 Grid (float cellsize, int sizex, int sizey)
 
 Grid (const QRectF rect_metric, const float cellsize)
 create from a metric rect More...
 
 Grid (const Grid< float > &toCopy)
 
bool loadGridFromFile (const QString &fileName)
 load a grid from an ASCII grid file the coordinates and cell size remain as in the grid file. More...
 
 ~Grid ()
 
void clear ()
 
bool setup (const float cellsize, const int sizex, const int sizey)
 
bool setup (const QRectF &rect, const double cellsize)
 
bool setup (const Grid< float > &source)
 
void initialize (const float &value)
 
void wipe ()
 write 0-bytes with memcpy to the whole area More...
 
void wipe (const float value)
 overwrite the whole area with "value" size of T must be the size of "int" ERRORNOUS!!! More...
 
void copy (const Grid< float > &source)
 copies the content of the source grid to this grid. More...
 
Grid< double > * toDouble () const
 create a double grid (same size as this grid) and convert this grid to double values. More...
 
int sizeX () const
 
int sizeY () const
 
float metricSizeX () const
 
float metricSizeY () const
 
QRectF metricRect () const
 get the metric rectangle of the grid More...
 
void setMetricRect (QRectF rect)
 set the metric rectangle. Use with care! No further checks are executed! More...
 
QRect rectangle () const
 get the rectangle of the grid in terms of indices More...
 
float cellsize () const
 get the length of one pixel of the grid More...
 
int count () const
 returns the number of elements of the grid More...
 
bool isEmpty () const
 returns false if the grid was not setup More...
 
const float & operator() (const int ix, const int iy) const
 access (const) with index variables. use int. More...
 
const float & operator() (const float x, const float y) const
 access (const) using metric variables. use float. More...
 
const float & operator[] (const QPoint &p) const
 access value of grid with a QPoint More...
 
float & operator[] (const int idx) const
 use the square brackets to access by index More...
 
float & operator[] (const QPointF &p)
 use the square bracket to access by QPointF More...
 
float & operator[] (const QPoint &p)
 use the square bracket to access by QPoint More...
 
float & valueAtIndex (const QPoint &pos)
 value at position defined by a QPoint defining the two indices (x,y) More...
 
float & valueAtIndex (const int ix, const int iy)
 const value at position defined by indices (x,y) More...
 
float & valueAtIndex (const int index)
 get a ref ot value at (one-dimensional) index 'index'. More...
 
int index (const int ix, const int iy)
 get the 0-based index of the cell with indices ix and iy. More...
 
int index (const QPoint &pos)
 get the 0-based index of the cell at 'pos'. More...
 
const float & constValueAtIndex (const QPoint &pos) const
 value at position defined by a (integer) QPoint More...
 
const float & constValueAtIndex (const int ix, const int iy) const
 value at position defined by a pair of integer coordinates More...
 
const float & constValueAtIndex (const int index) const
 value at position defined by the index within the grid More...
 
float & valueAt (const QPointF &posf)
 value at position defined by metric coordinates (QPointF) More...
 
float & valueAt (const float x, const float y)
 value at position defined by metric coordinates (x,y) More...
 
const float & constValueAt (const QPointF &posf) const
 value at position defined by metric coordinates (QPointF) More...
 
const float & constValueAt (const float x, const float y) const
 value at position defined by metric coordinates (x,y) More...
 
bool coordValid (const float x, const float y) const
 
bool coordValid (const QPointF &pos) const
 
QPoint indexAt (const QPointF &pos) const
 get index of value at position pos (metric) More...
 
QPoint indexOf (const int index) const
 get index (x/y) of the (linear) index 'index' (0..count-1) More...
 
QPoint indexOf (const float *element) const
 retrieve index (x/y) of the pointer element. returns -1/-1 if element is not valid. More...
 
bool isIndexValid (const QPoint &pos) const
 return true, if position is within the grid More...
 
bool isIndexValid (const int x, const int y) const
 return true, if index is within the grid More...
 
int index2 (int idx) const
 returns the index of an aligned grid (with the same size and matching origin) with the double cell size (e.g. to scale from a 10m grid to a 20m grid) More...
 
int index5 (int idx) const
 returns the index of an aligned grid (the same size) with the 5 times bigger cells (e.g. to scale from a 2m grid to a 10m grid) More...
 
int index10 (int idx) const
 returns the index of an aligned grid (the same size) with the 10 times bigger cells (e.g. to scale from a 2m grid to a 20m grid) More...
 
void validate (QPoint &pos) const
 force More...
 
QPointF cellCenterPoint (const QPoint &pos) const
 get the (metric) centerpoint of cell with index pos More...
 
QPointF cellCenterPoint (const int &index) const
 get the metric cell center point of the cell given by index 'index' More...
 
QPointF cellCenterPoint (float *ptr)
 get the metric cell center point of the cell given py the pointer More...
 
QRectF cellRect (const QPoint &pos) const
 get the metric rectangle of the cell with index @pos More...
 
float * begin () const
 get "iterator" pointer More...
 
float * end () const
 get iterator end-pointer More...
 
float max () const
 retrieve the maximum value of a grid More...
 
float min () const
 retrieve the minimum value of a grid More...
 
float sum () const
 retrieve the sum of the grid More...
 
float avg () const
 retrieve the average value of a grid More...
 
void add (const float &summand)
 
void multiply (const float &factor)
 
void limit (const float min_value, const float max_value)
 limit each cell value to (including) min_value and (including) max_value More...
 
Grid< float > averaged (const int factor, const int offsetx=0, const int offsety=0) const
 creates a grid with lower resolution and averaged cell values. More...
 
Grid< float > normalized (const float targetvalue) const
 normalized returns a normalized grid, in a way that the sum() = More...
 
float * ptr (int x, int y)
 get a pointer to the element indexed by "x" and "y" More...
 
double distance (const QPoint &p1, const QPoint &p2)
 distance (metric) between p1 and p2 More...
 
const QPoint randomPosition () const
 returns a (valid) random position within the grid More...
 
int floodFill (QPoint start, float old_color, float color, int max_fill=-1)
 applies a flood fill algorithm to the grid starting at 'start' fills the contingent area with value 'old_color' with 'color' (or stops when 'max_fill' pixels have been filled) returns the number of filled pixels More...
 

Detailed Description

DEM is a digital elevation model class.

It uses a float grid internally. slope is calculated in "%", i.e. a value of 1 is 45deg (90deg -> inf)

The aspect angles are defined as follows (like ArcGIS, values in degrees): 0 N 270 W x E 90 S 180

Values for height of -1 indicate "out of scope", "invalid" values

Constructor & Destructor Documentation

◆ DEM()

DEM::DEM ( const QString &  fileName)
inline

Member Function Documentation

◆ aspectGrid()

const FloatGrid * DEM::aspectGrid ( ) const
inline

◆ createSlopeGrid()

void DEM::createSlopeGrid ( ) const

◆ direction()

float DEM::direction ( const float  x,
const float  y 
)

get the direction of the slope at point (x/y) if the slope at the point is 0, "north" (0) is returned.

◆ elevation() [1/2]

float DEM::elevation ( const float  x,
const float  y 
) const
inline

get the elevation (m) at point (x/y)

◆ elevation() [2/2]

float DEM::elevation ( const QPointF  p) const
inline

◆ loadFromFile()

bool DEM::loadFromFile ( const QString &  fileName)

loads a DEM from a ESRI style text file.

internally, the DEM has always a resolution of 10m

◆ orientation() [1/2]

float DEM::orientation ( const float  x,
const float  y,
float &  rslope_angle,
float &  rslope_aspect 
)
inline

◆ orientation() [2/2]

float DEM::orientation ( const QPointF &  point,
float &  rslope_angle,
float &  rslope_aspect 
) const

get orientation at specific point (x,y) and height

calculate slope and aspect at a given point.

results are params per reference. returns the height at point (x/y) calculation follows: Burrough, P. A. and McDonell, R.A., 1998.Principles of Geographical Information Systems.(Oxford University Press, New York), p. 190. http://uqu.edu.sa/files2/tiny_mce/plugins/filemanager/files/4280125/Principles%20of%20Geographical%20Information%20Systems.pdf

Parameters
pointmetric coordinates of point to derive orientation
rslope_angleRESULTING (passed by reference) slope angle as percentage (i.e: 1:=45 degrees)
rslope_aspectRESULTING slope direction in degrees (0: North, 90: east, 180: south, 270: west)

◆ slope()

float DEM::slope ( const float  x,
const float  y 
)

◆ slopeGrid()

const FloatGrid * DEM::slopeGrid ( ) const
inline

◆ viewGrid()

const FloatGrid * DEM::viewGrid ( ) const
inline

The documentation for this class was generated from the following files: