783 changes: 783 additions & 0 deletions src/analysis/raster/qgsrelief.cpp

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions src/analysis/raster/qgsrelief.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/***************************************************************************
qgsrelief.h - description
---------------------------
begin : November 2011
copyright : (C) 20011 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSRELIEF_H
#define QGSRELIEF_H

#include <QColor>
#include <QMap>
#include <QPair>
#include <QString>
#include "gdal.h"

class QgsAspectFilter;
class QgsSlopeFilter;
class QgsHillshadeFilter;
class QProgressDialog;

/**Produces coloured relief rasters from DEM*/
class ANALYSIS_EXPORT QgsRelief
{
public:
struct ReliefColor
{
ReliefColor( const QColor& c, double min, double max ): color( c ), minElevation( min ), maxElevation( max ) { }
QColor color;
double minElevation;
double maxElevation;
};

QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
~QgsRelief();

/**Starts the calculation, reads from mInputFile and stores the result in mOutputFile
@param p progress dialog that receives update and that is checked for abort. 0 if no progress bar is needed.
@return 0 in case of success*/
int processRaster( QProgressDialog* p );

double zFactor() const { return mZFactor; }
void setZFactor( double factor ) { mZFactor = factor; }

void clearReliefColors();
void addReliefColorClass( const ReliefColor& color );
const QList< ReliefColor >& reliefColors() const { return mReliefColors; }
void setReliefColors( const QList< ReliefColor >& c ) { mReliefColors = c; }

/**Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression
@return true in case of success*/
QList< ReliefColor > calculateOptimizedReliefClasses();

/**Write frequency of elevation values to file for manual inspection*/
bool exportFrequencyDistributionToCsv( const QString& file );

private:

QString mInputFile;
QString mOutputFile;
QString mOutputFormat;

double mCellSizeX;
double mCellSizeY;
/**The nodata value of the input layer*/
float mInputNodataValue;
/**The nodata value of the output layer*/
float mOutputNodataValue;

double mZFactor;

QgsSlopeFilter* mSlopeFilter;
QgsAspectFilter* mAspectFilter;
QgsHillshadeFilter* mHillshadeFilter285;
QgsHillshadeFilter* mHillshadeFilter300;
QgsHillshadeFilter* mHillshadeFilter315;

//relief colors and corresponding elevations
QList< ReliefColor > mReliefColors;

bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
int* red, int* green, int* blue );

/**Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction*/
GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
/**Opens the output driver and tests if it supports the creation of a new dataset
@return NULL on error and the driver handle on success*/
GDALDriverH openOutputDriver();
/**Opens the output file and sets the same geotransform and CRS as the input data
@return the output dataset or NULL in case of error*/
GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );

/**Set elevation color*/
bool setElevationColor( double elevation, int* red, int* green, int* blue );

/**Sets relief colors*/
void setDefaultReliefColors();
/**Returns class (0-255) for an elevation value
@return elevation class or -1 in case of error*/
int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
/**Do one iteration of class break optimisation (algorithm from Garcia and Rodriguez)*/
void optimiseClassBreaks( QList<int>& breaks, double* frequencies );
/**Calculates coefficients a (slope) and b (y value for x=0)
@param input data points ( elevation class / frequency )*/
bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b );
};

#endif // QGSRELIEF_H
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsruggednessfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ANALYSIS_EXPORT QgsRuggednessFilter: public QgsNineCellFilter
~QgsRuggednessFilter();

protected:
/**Calculates output value from nine input values. The input values and the output value can be equal to the
/**Calculates output value from nine input values. The input values and the output value can be equal to the \
nodata value if not present or outside of the border. Must be implemented by subclasses*/
float processNineCellWindow( float* x11, float* x21, float* x31, \
float* x12, float* x22, float* x32, float* x13, float* x23, float* x33 );
Expand Down
1 change: 0 additions & 1 deletion src/analysis/raster/qgsslopefilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class ANALYSIS_EXPORT QgsSlopeFilter: public QgsDerivativeFilter
QgsSlopeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
~QgsSlopeFilter();

protected:
/**Calculates output value from nine input values. The input values and the output value can be equal to the
nodata value if not present or outside of the border. Must be implemented by subclasses*/
float processNineCellWindow( float* x11, float* x21, float* x31,
Expand Down
333 changes: 262 additions & 71 deletions src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisdialog.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
/***************************************************************************
qgsrasterterrainanalysisdialog.h - description
-----------------------------
begin : August 8th, 2009
copyright : (C) 2009 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSRASTERTERRAINANALYSISDIALOG_H
#define QGSRASTERTERRAINANALYSISDIALOG_H

#include "ui_qgsrasterterrainanalysisdialogbase.h"

class QgisInterface;
#include "qgsrelief.h"

class QgsRasterTerrainAnalysisDialog: public QDialog, private Ui::QgsRasterTerrainAnalysisDialogBase
{
Q_OBJECT
public:
QgsRasterTerrainAnalysisDialog( QgisInterface* iface, QWidget* parent = 0 );

enum DisplayMode
{
NoParameter,
HillshadeInput,
ReliefInput
};

QgsRasterTerrainAnalysisDialog( DisplayMode mode = NoParameter, QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsRasterTerrainAnalysisDialog();

QString selectedInputLayerId() const;
QString selectedDriverKey() const;
QString selectedOuputFilePath() const;
QString selectedAnalysisMethod() const;
bool addLayerToProject() const;
QList< QgsRelief::ReliefColor > reliefColors() const;
QString inputFile() const;
QString outputFile() const;
QString outputFormat() const;

bool addResultToProject() const;
double zFactor() const;
double lightAzimuth() const;
double lightAngle() const;

private slots:
void on_mOutputLayerLineEdit_textChanged( const QString& text );
void on_mOutputLayerPushButton_clicked();
void on_mAutomaticColorButton_clicked();
void on_mOutputLayerToolButton_clicked();
void on_mAddClassButton_clicked();
void on_mRemoveClassButton_clicked();
void on_mUpPushButton_clicked();
void on_mDownPushButton_clicked();
void on_mReliefClassTreeWidget_itemDoubleClicked( QTreeWidgetItem* item, int column );
void on_mExportToCsvButton_clicked();
void on_mExportColorsButton_clicked();
void on_mImportColorsButton_clicked();
void on_mButtonBox_accepted();

private:
QgisInterface* mIface;

/**Stores relation between driver name and extension*/
QMap<QString, QString> mDriverExtensionMap;
};

#endif // QGSRASTERTERRAINANALYSISDIALOG_H
#endif //QGSRASTERTERRAINANALYSISDIALOG_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,100 +6,209 @@
<rect>
<x>0</x>
<y>0</y>
<width>355</width>
<height>176</height>
<width>492</width>
<height>473</height>
</rect>
</property>
<property name="windowTitle">
<string>Raster based terrain analysis</string>
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="mAnalysisLabel">
<widget class="QLabel" name="mElevationLayerLabel">
<property name="text">
<string>Analysis</string>
</property>
<property name="buddy">
<cstring>mAnalysisComboBox</cstring>
<string>Elevation layer</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="mAnalysisComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QComboBox" name="mElevationLayerComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mInputLayerLabel">
<property name="text">
<string>Input layer</string>
</property>
<property name="buddy">
<cstring>mInputLayerComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="mInputLayerComboBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mOutputLayerLabel">
<property name="text">
<string>Output layer</string>
</property>
<property name="buddy">
<cstring>mOutputLayerPushButton</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QLineEdit" name="mOutputLayerLineEdit"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="mOutputLayerPushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<item row="1" column="2">
<widget class="QToolButton" name="mOutputLayerToolButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="mOutputFormatLabel">
<property name="text">
<string>Output format</string>
</property>
<property name="buddy">
<cstring>mOutputFormatComboBox</cstring>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="mOutputFormatComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mZFactorLabel">
<property name="text">
<string>Z factor</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QComboBox" name="mOutputFormatComboBox"/>
<widget class="QLineEdit" name="mZFactorLineEdit"/>
</item>
<item row="4" column="0" colspan="3">
<item row="4" column="0">
<widget class="QCheckBox" name="mAddResultToProjectCheckBox">
<property name="text">
<string>Add result to project</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="mIlluminationGroupBox">
<property name="title">
<string>Illumination</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="mLightAzimuthLabel">
<property name="text">
<string>Azimuth (horizontal angle)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="mLightAzimuthAngleSpinBox">
<property name="maximum">
<double>360.000000000000000</double>
</property>
<property name="value">
<double>300.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mLightVerticalAngleLabel">
<property name="text">
<string>Vertical angle</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="mLightVerticalAngleSpinBox">
<property name="maximum">
<double>90.000000000000000</double>
</property>
<property name="value">
<double>40.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QGroupBox" name="mReliefColorsGroupBox">
<property name="title">
<string>Relief colors</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="mAutomaticColorButton">
<property name="text">
<string>Create automatically</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="mExportToCsvButton">
<property name="text">
<string>Export distribution...</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>268</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="mUpPushButton">
<property name="text">
<string>Up</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="mDownPushButton">
<property name="text">
<string>Down</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="mAddClassButton">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="mRemoveClassButton">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="8">
<widget class="QTreeWidget" name="mReliefClassTreeWidget">
<column>
<property name="text">
<string>Lower bound</string>
</property>
</column>
<column>
<property name="text">
<string>Upper bound</string>
</property>
</column>
<column>
<property name="text">
<string>Color</string>
</property>
</column>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="mExportColorsButton">
<property name="text">
<string>Export colors...</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="mImportColorsButton">
<property name="text">
<string>Import colors...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -111,15 +220,6 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>mAnalysisComboBox</tabstop>
<tabstop>mInputLayerComboBox</tabstop>
<tabstop>mOutputLayerLineEdit</tabstop>
<tabstop>mOutputLayerPushButton</tabstop>
<tabstop>mOutputFormatComboBox</tabstop>
<tabstop>mAddResultToProjectCheckBox</tabstop>
<tabstop>mButtonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
Expand Down
176 changes: 130 additions & 46 deletions src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,26 @@
#include "qgsmaplayer.h"
#include "qgsmaplayerregistry.h"
#include "qgsaspectfilter.h"
#include "qgshillshadefilter.h"
#include "qgsslopefilter.h"
#include "qgsruggednessfilter.h"
#include "qgstotalcurvaturefilter.h"
#include "qgsrelief.h"
#include "qgsrasterterrainanalysisdialog.h"
#include <QAction>
#include <QFileInfo>
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QProgressDialog>

static const QString name_ = QObject::tr( "Raster Terrain Analysis plugin" );
static const QString description_ = QObject::tr( "A plugin for raster based terrain analysis" );
static const QString category_ = QObject::tr( "Raster" );
static const QString version_ = QObject::tr( "Version 0.1" );
static const QString icon_ = ":/raster/raster_terrain_icon.png";
static const QString category_ = QObject::tr( "Raster" );

QgsRasterTerrainAnalysisPlugin::QgsRasterTerrainAnalysisPlugin( QgisInterface* iface ): mIface( iface ), mAction( 0 )
QgsRasterTerrainAnalysisPlugin::QgsRasterTerrainAnalysisPlugin( QgisInterface* iface ): mIface( iface ), mTerrainAnalysisMenu( 0 )
{

}
Expand All @@ -50,69 +55,148 @@ void QgsRasterTerrainAnalysisPlugin::initGui()
//create Action
if ( mIface )
{
mAction = new QAction( QIcon( ":/raster/raster_terrain_icon.png" ), tr( "&Raster based terrain analysis" ), 0 );
QObject::connect( mAction, SIGNAL( triggered() ), this, SLOT( run() ) );
mIface->addRasterToolBarIcon( mAction );
mIface->addPluginToRasterMenu( tr( "&Raster based terrain analysis" ), mAction );
//find raster menu
QString rasterText = QCoreApplication::translate( "QgisApp", "&Raster" );
QMainWindow* mainWindow = qobject_cast<QMainWindow*>( mIface->mainWindow() );
if ( !mainWindow )
{
return;
}

QMenuBar* menuBar = mainWindow->menuBar();
if ( !menuBar )
{
return;
}

QMenu* rasterMenu = 0;
QList<QAction *> menuBarActions = menuBar->actions();
QList<QAction *>::iterator menuActionIt = menuBarActions.begin();
for ( ; menuActionIt != menuBarActions.end(); ++menuActionIt )
{
if (( *menuActionIt )->menu() && ( *menuActionIt )->menu()->title() == rasterText )
{
rasterMenu = ( *menuActionIt )->menu();
rasterMenu->addSeparator();
break;
}
}

if ( !rasterMenu )
{
return;
}

mTerrainAnalysisMenu = new QMenu( tr( "Terrain analysis" ) );
mTerrainAnalysisMenu->addAction( tr( "Slope" ), this, SLOT( slope() ) );
mTerrainAnalysisMenu->addAction( tr( "Aspect" ), this, SLOT( aspect() ) );
mTerrainAnalysisMenu->addAction( tr( "Hillshade" ), this, SLOT( hillshade() ) );
mTerrainAnalysisMenu->addAction( tr( "Relief" ), this, SLOT( relief() ) );
mTerrainAnalysisMenu->addAction( tr( "Ruggedness index" ), this, SLOT( ruggedness() ) );
rasterMenu->addMenu( mTerrainAnalysisMenu );
}
}

void QgsRasterTerrainAnalysisPlugin::unload()
{
if ( mIface )
{
mIface->removePluginRasterMenu( tr( "&Raster based terrain analysis" ), mAction );
mIface ->removeRasterToolBarIcon( mAction );
delete mAction;
delete mTerrainAnalysisMenu;
}
}

void QgsRasterTerrainAnalysisPlugin::run()
void QgsRasterTerrainAnalysisPlugin::hillshade()
{
QgsRasterTerrainAnalysisDialog d( mIface );
QgsRasterTerrainAnalysisDialog d( QgsRasterTerrainAnalysisDialog::HillshadeInput );
d.setWindowTitle( tr( "Hillshade" ) );
if ( d.exec() == QDialog::Accepted )
{
//get input layer from id
QString inputLayerId = d.selectedInputLayerId();
QgsMapLayer* inputLayer = QgsMapLayerRegistry::instance()->mapLayer( inputLayerId );
if ( !inputLayer )
QString outputFile = d.outputFile();
QgsHillshadeFilter hillshade( d.inputFile(), outputFile, d.outputFormat(), d.lightAzimuth(), d.lightAngle() );
hillshade.setZFactor( d.zFactor() );
QProgressDialog p( tr( "Calculating hillshade..." ), tr( "Abort" ), 0, 0 );
p.setWindowModality( Qt::WindowModal );
hillshade.processRaster( &p );
if ( d.addResultToProject() )
{
return;
mIface->addRasterLayer( outputFile, QFileInfo( outputFile ).baseName() );
}
QString inputFilePath = inputLayer->source();

QString analysisMethod = d.selectedAnalysisMethod();
QString selectedFormat = d.selectedDriverKey();
QString outputFile = d.selectedOuputFilePath();
}
}

QgsNineCellFilter* filter = 0;
if ( d.selectedAnalysisMethod() == tr( "Slope" ) )
{
filter = new QgsSlopeFilter( inputFilePath, outputFile, selectedFormat );
}
else if ( d.selectedAnalysisMethod() == tr( "Aspect" ) )
void QgsRasterTerrainAnalysisPlugin::relief()
{
QgsRasterTerrainAnalysisDialog d( QgsRasterTerrainAnalysisDialog::ReliefInput );
d.setWindowTitle( tr( "Relief" ) );
if ( d.exec() == QDialog::Accepted )
{
QString outputFile = d.outputFile();
QgsRelief relief( d.inputFile(), outputFile, d.outputFormat() );
relief.setReliefColors( d.reliefColors() );
relief.setZFactor( d.zFactor() );
QProgressDialog p( tr( "Calculating relief..." ), tr( "Abort" ), 0, 0 );
p.setWindowModality( Qt::WindowModal );
relief.processRaster( &p );
if ( d.addResultToProject( ) )
{
filter = new QgsAspectFilter( inputFilePath, outputFile, selectedFormat );
mIface->addRasterLayer( outputFile, QFileInfo( outputFile ).baseName() );
}
else if ( d.selectedAnalysisMethod() == tr( "Ruggedness index" ) )
}
}

void QgsRasterTerrainAnalysisPlugin::slope()
{
QgsRasterTerrainAnalysisDialog d( QgsRasterTerrainAnalysisDialog::NoParameter );
d.setWindowTitle( tr( "Slope" ) );
if ( d.exec() == QDialog::Accepted )
{
QString outputFile = d.outputFile();
QgsSlopeFilter slope( d.inputFile(), outputFile, d.outputFormat() );
slope.setZFactor( d.zFactor() );
QProgressDialog p( tr( "Calculating slope..." ), tr( "Abort" ), 0, 0 );
p.setWindowModality( Qt::WindowModal );
slope.processRaster( &p );
if ( d.addResultToProject( ) )
{
filter = new QgsRuggednessFilter( inputFilePath, outputFile, selectedFormat );
mIface->addRasterLayer( outputFile, QFileInfo( outputFile ).baseName() );
}
else if ( d.selectedAnalysisMethod() == tr( "Total curvature" ) )
}
}

void QgsRasterTerrainAnalysisPlugin::aspect()
{
QgsRasterTerrainAnalysisDialog d( QgsRasterTerrainAnalysisDialog::NoParameter );
d.setWindowTitle( tr( "Aspect" ) );
if ( d.exec() == QDialog::Accepted )
{
QString outputFile = d.outputFile();
QgsAspectFilter aspect( d.inputFile(), outputFile, d.outputFormat() );
aspect.setZFactor( d.zFactor() );
QProgressDialog p( tr( "Calculating aspect..." ), tr( "Abort" ), 0, 0 );
p.setWindowModality( Qt::WindowModal );
aspect.processRaster( &p );
if ( d.addResultToProject( ) )
{
filter = new QgsTotalCurvatureFilter( inputFilePath, outputFile, selectedFormat );
mIface->addRasterLayer( outputFile, QFileInfo( outputFile ).baseName() );
}
}
}

if ( filter )
void QgsRasterTerrainAnalysisPlugin::ruggedness()
{
QgsRasterTerrainAnalysisDialog d( QgsRasterTerrainAnalysisDialog::NoParameter );
d.setWindowTitle( tr( "Ruggedness" ) );
if ( d.exec() == QDialog::Accepted )
{
QString outputFile = d.outputFile();
QgsRuggednessFilter ruggedness( d.inputFile(), outputFile, d.outputFormat() );
ruggedness.setZFactor( d.zFactor() );
QProgressDialog p( tr( "Calculating ruggedness..." ), tr( "Abort" ), 0, 0 );
p.setWindowModality( Qt::WindowModal );
ruggedness.processRaster( &p );
if ( d.addResultToProject( ) )
{
QProgressDialog p( tr( "Calculating " ) + d.selectedAnalysisMethod() + "...", tr( "Abort..." ), 0, 0 );
p.setWindowModality( Qt::WindowModal );
filter->processRaster( &p );
delete filter;
if ( d.addLayerToProject() )
{
mIface->addRasterLayer( outputFile, QFileInfo( outputFile ).baseName() );
}
mIface->addRasterLayer( outputFile, QFileInfo( outputFile ).baseName() );
}
}
}
Expand All @@ -133,11 +217,6 @@ QGISEXTERN QString description()
return description_;
}

QGISEXTERN QString category()
{
return category_;
}

QGISEXTERN QString version()
{
return version_;
Expand All @@ -158,4 +237,9 @@ QGISEXTERN void unload( QgisPlugin* pluginPointer )
delete pluginPointer;
}

QGISEXTERN QString category()
{
return category_;
}


Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

class QgsInterface;
class QAction;
class QMenu;

/**A plugin for raster based terrain analysis (e.g. slope, aspect, ruggedness)*/
class QgsRasterTerrainAnalysisPlugin: public QObject, public QgisPlugin
Expand All @@ -38,12 +39,15 @@ class QgsRasterTerrainAnalysisPlugin: public QObject, public QgisPlugin
void unload();

private slots:
/**Select input file, output file, format and analysis method*/
void run();
void hillshade();
void relief();
void slope();
void aspect();
void ruggedness();

private:
QgisInterface* mIface;
QAction* mAction;
QMenu* mTerrainAnalysisMenu;
};

#endif // QGSRASTERTERRAINANALYSISPLUGIN_H