Quantum GIS API Documentation  1.8
Classes | Public Member Functions | Private Member Functions | Private Attributes
QgsRelief Class Reference

Produces coloured relief rasters from DEM. More...

#include <qgsrelief.h>

Collaboration diagram for QgsRelief:
Collaboration graph
[legend]

List of all members.

Classes

struct  ReliefColor

Public Member Functions

 QgsRelief (const QString &inputFile, const QString &outputFile, const QString &outputFormat)
 ~QgsRelief ()
int processRaster (QProgressDialog *p)
 Starts the calculation, reads from mInputFile and stores the result in mOutputFile.
double zFactor () const
void setZFactor (double factor)
void clearReliefColors ()
void addReliefColorClass (const ReliefColor &color)
const QList< ReliefColor > & reliefColors () const
void setReliefColors (const QList< ReliefColor > &c)
QList< ReliefColorcalculateOptimizedReliefClasses ()
 Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression.
bool exportFrequencyDistributionToCsv (const QString &file)
 Write frequency of elevation values to file for manual inspection.

Private Member Functions

bool processNineCellWindow (float *x1, float *x2, float *x3, float *x4, float *x5, float *x6, float *x7, float *x8, float *x9, unsigned char *red, unsigned char *green, unsigned char *blue)
GDALDatasetH openInputFile (int &nCellsX, int &nCellsY)
 Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction.
GDALDriverH openOutputDriver ()
 Opens the output driver and tests if it supports the creation of a new dataset.
GDALDatasetH openOutputFile (GDALDatasetH inputDataset, GDALDriverH outputDriver)
 Opens the output file and sets the same geotransform and CRS as the input data.
bool setElevationColor (double elevation, int *red, int *green, int *blue)
 Set elevation color.
void setDefaultReliefColors ()
 Sets relief colors.
int frequencyClassForElevation (double elevation, double minElevation, double elevationClassRange)
 Returns class (0-255) for an elevation value.
void optimiseClassBreaks (QList< int > &breaks, double *frequencies)
 Do one iteration of class break optimisation (algorithm from Garcia and Rodriguez)
bool calculateRegression (const QList< QPair< int, double > > &input, double &a, double &b)
 Calculates coefficients a and b.

Private Attributes

QString mInputFile
QString mOutputFile
QString mOutputFormat
double mCellSizeX
double mCellSizeY
float mInputNodataValue
 The nodata value of the input layer.
float mOutputNodataValue
 The nodata value of the output layer.
double mZFactor
QgsSlopeFiltermSlopeFilter
QgsAspectFiltermAspectFilter
QgsHillshadeFiltermHillshadeFilter285
QgsHillshadeFiltermHillshadeFilter300
QgsHillshadeFiltermHillshadeFilter315
QList< ReliefColormReliefColors

Detailed Description

Produces coloured relief rasters from DEM.

Definition at line 33 of file qgsrelief.h.


Constructor & Destructor Documentation

QgsRelief::QgsRelief ( const QString &  inputFile,
const QString &  outputFile,
const QString &  outputFormat 
)

Member Function Documentation

Definition at line 63 of file qgsrelief.cpp.

References mReliefColors.

Referenced by setDefaultReliefColors().

Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression.

Returns:
true in case of success

Definition at line 562 of file qgsrelief.cpp.

References frequencyClassForElevation(), openInputFile(), and optimiseClassBreaks().

bool QgsRelief::calculateRegression ( const QList< QPair< int, double > > &  input,
double &  a,
double &  b 
) [private]

Calculates coefficients a and b.

Parameters:
inputdata points ( elevation class / frequency )
aslope
by value for x=0

Definition at line 755 of file qgsrelief.cpp.

Referenced by optimiseClassBreaks().

Definition at line 58 of file qgsrelief.cpp.

References mReliefColors.

Referenced by setDefaultReliefColors().

bool QgsRelief::exportFrequencyDistributionToCsv ( const QString &  file)

Write frequency of elevation values to file for manual inspection.

Definition at line 481 of file qgsrelief.cpp.

References frequencyClassForElevation(), and openInputFile().

int QgsRelief::frequencyClassForElevation ( double  elevation,
double  minElevation,
double  elevationClassRange 
) [private]

Returns class (0-255) for an elevation value.

Returns:
elevation class or -1 in case of error

Definition at line 750 of file qgsrelief.cpp.

Referenced by calculateOptimizedReliefClasses(), and exportFrequencyDistributionToCsv().

GDALDatasetH QgsRelief::openInputFile ( int &  nCellsX,
int &  nCellsY 
) [private]

Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction.

Definition at line 391 of file qgsrelief.cpp.

References mInputFile, and TO8.

Referenced by calculateOptimizedReliefClasses(), exportFrequencyDistributionToCsv(), and processRaster().

GDALDriverH QgsRelief::openOutputDriver ( ) [private]

Opens the output driver and tests if it supports the creation of a new dataset.

Returns:
NULL on error and the driver handle on success

Definition at line 409 of file qgsrelief.cpp.

References mOutputFormat.

Referenced by processRaster().

GDALDatasetH QgsRelief::openOutputFile ( GDALDatasetH  inputDataset,
GDALDriverH  outputDriver 
) [private]

Opens the output file and sets the same geotransform and CRS as the input data.

Returns:
the output dataset or NULL in case of error

Definition at line 430 of file qgsrelief.cpp.

References mCellSizeX, mCellSizeY, and mOutputFile.

Referenced by processRaster().

void QgsRelief::optimiseClassBreaks ( QList< int > &  breaks,
double *  frequencies 
) [private]

Do one iteration of class break optimisation (algorithm from Garcia and Rodriguez)

Definition at line 680 of file qgsrelief.cpp.

References calculateRegression(), and doubleNear().

Referenced by calculateOptimizedReliefClasses().

bool QgsRelief::processNineCellWindow ( float *  x1,
float *  x2,
float *  x3,
float *  x4,
float *  x5,
float *  x6,
float *  x7,
float *  x8,
float *  x9,
unsigned char *  red,
unsigned char *  green,
unsigned char *  blue 
) [private]
int QgsRelief::processRaster ( QProgressDialog *  p)

Starts the calculation, reads from mInputFile and stores the result in mOutputFile.

Parameters:
pprogress dialog that receives update and that is checked for abort. 0 if no progress bar is needed.
Returns:
0 in case of success

Definition at line 79 of file qgsrelief.cpp.

References mAspectFilter, mCellSizeX, mCellSizeY, mHillshadeFilter285, mHillshadeFilter300, mHillshadeFilter315, mInputNodataValue, mOutputFile, mOutputNodataValue, mSlopeFilter, mZFactor, openInputFile(), openOutputDriver(), openOutputFile(), processNineCellWindow(), QgsNineCellFilter::setCellSizeX(), QgsNineCellFilter::setCellSizeY(), QgsNineCellFilter::setInputNodataValue(), QgsNineCellFilter::setOutputNodataValue(), and QgsNineCellFilter::setZFactor().

const QList< ReliefColor >& QgsRelief::reliefColors ( ) const [inline]

Definition at line 57 of file qgsrelief.h.

Sets relief colors.

Definition at line 68 of file qgsrelief.cpp.

References addReliefColorClass(), and clearReliefColors().

bool QgsRelief::setElevationColor ( double  elevation,
int *  red,
int *  green,
int *  blue 
) [private]

Set elevation color.

Definition at line 372 of file qgsrelief.cpp.

References mReliefColors.

Referenced by processNineCellWindow().

void QgsRelief::setReliefColors ( const QList< ReliefColor > &  c) [inline]

Definition at line 58 of file qgsrelief.h.

void QgsRelief::setZFactor ( double  factor) [inline]

Definition at line 53 of file qgsrelief.h.

double QgsRelief::zFactor ( ) const [inline]

Definition at line 52 of file qgsrelief.h.


Member Data Documentation

Definition at line 83 of file qgsrelief.h.

Referenced by processNineCellWindow(), processRaster(), QgsRelief(), and ~QgsRelief().

double QgsRelief::mCellSizeX [private]

Definition at line 73 of file qgsrelief.h.

Referenced by openOutputFile(), and processRaster().

double QgsRelief::mCellSizeY [private]

Definition at line 74 of file qgsrelief.h.

Referenced by openOutputFile(), and processRaster().

Definition at line 84 of file qgsrelief.h.

Referenced by processNineCellWindow(), processRaster(), QgsRelief(), and ~QgsRelief().

Definition at line 85 of file qgsrelief.h.

Referenced by processNineCellWindow(), processRaster(), QgsRelief(), and ~QgsRelief().

Definition at line 86 of file qgsrelief.h.

Referenced by processNineCellWindow(), processRaster(), QgsRelief(), and ~QgsRelief().

QString QgsRelief::mInputFile [private]

Definition at line 69 of file qgsrelief.h.

Referenced by openInputFile().

The nodata value of the input layer.

Definition at line 76 of file qgsrelief.h.

Referenced by processRaster().

QString QgsRelief::mOutputFile [private]

Definition at line 70 of file qgsrelief.h.

Referenced by openOutputFile(), and processRaster().

QString QgsRelief::mOutputFormat [private]

Definition at line 71 of file qgsrelief.h.

Referenced by openOutputDriver().

The nodata value of the output layer.

Definition at line 78 of file qgsrelief.h.

Referenced by processNineCellWindow(), and processRaster().

Definition at line 89 of file qgsrelief.h.

Referenced by addReliefColorClass(), clearReliefColors(), and setElevationColor().

Definition at line 82 of file qgsrelief.h.

Referenced by processNineCellWindow(), processRaster(), QgsRelief(), and ~QgsRelief().

double QgsRelief::mZFactor [private]

Definition at line 80 of file qgsrelief.h.

Referenced by processRaster().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines