QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
analysis
raster
qgskde.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgskde.h
3
--------
4
Date : October 2016
5
Copyright : (C) 2016 by Nyall Dawson
6
Email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSKDE_H
17
#define QGSKDE_H
18
19
#include "
qgsogrutils.h
"
20
#include "
qgsrectangle.h
"
21
22
#include <QString>
23
24
// GDAL includes
25
#include <gdal.h>
26
#include <cpl_string.h>
27
#include <cpl_conv.h>
28
#include "qgis_analysis.h"
29
30
class
QgsFeatureSource
;
31
class
QgsFeature
;
32
33
39
class
ANALYSIS_EXPORT
QgsKernelDensityEstimation
40
{
41
public
:
43
enum class
KernelShape
SIP_MONKEYPATCH_SCOPEENUM_UNNEST
(
QgsKernelDensityEstimation
,
KernelShape
) : int
44
{
45
Quartic
SIP_MONKEYPATCH_COMPAT_NAME
( KernelQuartic ) = 0,
46
Triangular
SIP_MONKEYPATCH_COMPAT_NAME
( KernelTriangular ),
47
Uniform
SIP_MONKEYPATCH_COMPAT_NAME
( KernelUniform ),
48
Triweight
SIP_MONKEYPATCH_COMPAT_NAME
( KernelTriweight ),
49
Epanechnikov
SIP_MONKEYPATCH_COMPAT_NAME
( KernelEpanechnikov ),
50
};
51
53
enum class
OutputValues
SIP_MONKEYPATCH_SCOPEENUM_UNNEST
(
QgsKernelDensityEstimation
,
OutputValues
) : int
54
{
55
Raw
SIP_MONKEYPATCH_COMPAT_NAME
( OutputRaw ) = 0,
56
Scaled
SIP_MONKEYPATCH_COMPAT_NAME
( OutputScaled ),
57
};
58
60
enum class
Result
SIP_MONKEYPATCH_SCOPEENUM_UNNEST
(
QgsKernelDensityEstimation
,
Result
) : int
61
{
62
Success,
63
DriverError,
64
InvalidParameters,
65
FileCreationError,
66
RasterIoError,
67
};
68
70
struct
Parameters
71
{
73
QgsFeatureSource
*
source
=
nullptr
;
74
76
double
radius
;
77
79
QString
radiusField
;
80
82
QString
weightField
;
83
85
double
pixelSize
;
86
88
QgsKernelDensityEstimation::KernelShape
shape
;
89
91
double
decayRatio
;
92
94
QgsKernelDensityEstimation::OutputValues
outputValues
;
95
};
96
101
QgsKernelDensityEstimation
(
const
Parameters
¶meters,
const
QString &outputFile,
const
QString &outputFormat );
102
103
QgsKernelDensityEstimation
(
const
QgsKernelDensityEstimation
&other ) =
delete
;
104
QgsKernelDensityEstimation
&
operator=
(
const
QgsKernelDensityEstimation
&other ) =
delete
;
105
110
Result
run
();
111
118
Result
prepare
();
119
125
Result
addFeature
(
const
QgsFeature
&feature );
126
132
Result
finalise
();
133
134
private
:
136
double
calculateKernelValue(
double
distance,
double
bandwidth,
KernelShape
shape,
OutputValues
outputType )
const
;
138
double
uniformKernel(
double
distance,
double
bandwidth,
OutputValues
outputType )
const
;
140
double
quarticKernel(
double
distance,
double
bandwidth,
OutputValues
outputType )
const
;
142
double
triweightKernel(
double
distance,
double
bandwidth,
OutputValues
outputType )
const
;
144
double
epanechnikovKernel(
double
distance,
double
bandwidth,
OutputValues
outputType )
const
;
146
double
triangularKernel(
double
distance,
double
bandwidth,
OutputValues
outputType )
const
;
147
148
QgsRectangle
calculateBounds()
const
;
149
150
QgsFeatureSource
*mSource =
nullptr
;
151
152
QString mOutputFile;
153
QString mOutputFormat;
154
155
int
mRadiusField = -1;
156
int
mWeightField = -1;
157
double
mRadius;
158
double
mPixelSize;
159
QgsRectangle
mBounds;
160
161
KernelShape
mShape;
162
double
mDecay;
163
OutputValues
mOutputValues;
164
165
int
mBufferSize = -1;
166
167
gdal::dataset_unique_ptr
mDatasetH;
168
GDALRasterBandH mRasterBandH =
nullptr
;
169
171
bool
createEmptyLayer( GDALDriverH driver,
const
QgsRectangle
&bounds,
int
rows,
int
columns )
const
;
172
int
radiusSizeInPixels(
double
radius )
const
;
173
174
#ifdef SIP_RUN
175
QgsKernelDensityEstimation
(
const
QgsKernelDensityEstimation
&other );
176
#endif
177
};
178
179
#endif
// QGSKDE_H
QgsFeatureSource
An interface for objects which provide features via a getFeatures method.
Definition
qgsfeaturesource.h:37
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition
qgsfeature.h:60
QgsKernelDensityEstimation::QgsKernelDensityEstimation
QgsKernelDensityEstimation(const Parameters ¶meters, const QString &outputFile, const QString &outputFormat)
Constructor for QgsKernelDensityEstimation.
Definition
qgskde.cpp:24
QgsKernelDensityEstimation::run
Result run()
Runs the KDE calculation across the whole layer at once.
Definition
qgskde.cpp:41
QgsKernelDensityEstimation::QgsKernelDensityEstimation
QgsKernelDensityEstimation(const QgsKernelDensityEstimation &other)=delete
QgsKernelDensityEstimation::addFeature
Result addFeature(const QgsFeature &feature)
Adds a single feature to the KDE surface.
Definition
qgskde.cpp:104
QgsKernelDensityEstimation::finalise
Result finalise()
Finalises the output file.
Definition
qgskde.cpp:203
QgsKernelDensityEstimation::operator=
QgsKernelDensityEstimation & operator=(const QgsKernelDensityEstimation &other)=delete
QgsKernelDensityEstimation::KernelShape
KernelShape
Kernel shape type.
Definition
qgskde.h:44
QgsKernelDensityEstimation::OutputValues
OutputValues
Output values type.
Definition
qgskde.h:54
QgsKernelDensityEstimation::prepare
Result prepare()
Prepares the output file for writing and setups up the surface calculation.
Definition
qgskde.cpp:66
QgsKernelDensityEstimation::Result
Result
Result of operation.
Definition
qgskde.h:61
QgsRectangle
A rectangle specified with double values.
Definition
qgsrectangle.h:47
gdal::dataset_unique_ptr
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
Definition
qgsogrutils.h:144
SIP_MONKEYPATCH_SCOPEENUM_UNNEST
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition
qgis_sip.h:270
SIP_MONKEYPATCH_COMPAT_NAME
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition
qgis_sip.h:272
qgsogrutils.h
qgsrectangle.h
QgsKernelDensityEstimation::Parameters
KDE parameters.
Definition
qgskde.h:71
QgsKernelDensityEstimation::Parameters::outputValues
QgsKernelDensityEstimation::OutputValues outputValues
Type of output value.
Definition
qgskde.h:94
QgsKernelDensityEstimation::Parameters::radiusField
QString radiusField
Field for radius, or empty if using a fixed radius.
Definition
qgskde.h:79
QgsKernelDensityEstimation::Parameters::radius
double radius
Fixed radius, in map units.
Definition
qgskde.h:76
QgsKernelDensityEstimation::Parameters::source
QgsFeatureSource * source
Point feature source.
Definition
qgskde.h:73
QgsKernelDensityEstimation::Parameters::decayRatio
double decayRatio
Decay ratio (Triangular kernels only).
Definition
qgskde.h:91
QgsKernelDensityEstimation::Parameters::shape
QgsKernelDensityEstimation::KernelShape shape
Kernel shape.
Definition
qgskde.h:88
QgsKernelDensityEstimation::Parameters::weightField
QString weightField
Field name for weighting field, or empty if not using weights.
Definition
qgskde.h:82
QgsKernelDensityEstimation::Parameters::pixelSize
double pixelSize
Size of pixel in output file.
Definition
qgskde.h:85
Generated on
for QGIS API Documentation by
1.17.0