QgsKernelDensityEstimation class
Performs Kernel Density Estimation ("heatmap") calculations on a vector layer.
Contents
Public types
- struct Parameters
- KDE parameters.
- enum KernelShape { KernelQuartic = 0, KernelTriangular, KernelUniform, KernelTriweight, KernelEpanechnikov }
- Kernel shape type.
- enum OutputValues { OutputRaw = 0, OutputScaled }
- Output values type.
- enum Result { Success, DriverError, InvalidParameters, FileCreationError, RasterIoError }
- Result of operation.
Constructors, destructors, conversion operators
- QgsKernelDensityEstimation(const Parameters& parameters, const QString& outputFile, const QString& outputFormat)
- Constructor for QgsKernelDensityEstimation.
- QgsKernelDensityEstimation(const QgsKernelDensityEstimation& other) deleted
- QgsKernelDensityEstimation cannot be copied.
Public functions
- auto addFeature(const QgsFeature& feature) -> Result
- Adds a single feature to the KDE surface.
- auto finalise() -> Result
- Finalises the output file.
- auto operator=(const QgsKernelDensityEstimation& other) -> QgsKernelDensityEstimation& deleted
- QgsKernelDensityEstimation cannot be copied.
- auto prepare() -> Result
- Prepares the output file for writing and setups up the surface calculation.
- auto run() -> Result
- Runs the KDE calculation across the whole layer at once.
Enum documentation
enum QgsKernelDensityEstimation:: KernelShape
Kernel shape type.
| Enumerators | |
|---|---|
| KernelQuartic |
Quartic kernel. |
| KernelTriangular |
Triangular kernel. |
| KernelUniform |
Uniform (flat) kernel. |
| KernelTriweight |
Triweight kernel. |
| KernelEpanechnikov |
Epanechnikov kernel. |
enum QgsKernelDensityEstimation:: OutputValues
Output values type.
| Enumerators | |
|---|---|
| OutputRaw |
Output the raw KDE values. |
| OutputScaled |
Output mathematically correct scaled values. |
enum QgsKernelDensityEstimation:: Result
Result of operation.
| Enumerators | |
|---|---|
| Success |
Operation completed successfully. |
| DriverError |
Could not open the driver for the specified format. |
| InvalidParameters |
Input parameters were not valid. |
| FileCreationError |
Error creating output file. |
| RasterIoError |
Error writing to raster. |
Function documentation
QgsKernelDensityEstimation:: QgsKernelDensityEstimation(const Parameters& parameters,
const QString& outputFile,
const QString& outputFormat)
Constructor for QgsKernelDensityEstimation.
Requires a Parameters object specifying the options to use to generate the surface. The output path and file format are also required.
Result QgsKernelDensityEstimation:: addFeature(const QgsFeature& feature)
Adds a single feature to the KDE surface.
prepare() must be called before adding features.
Result QgsKernelDensityEstimation:: finalise()
Finalises the output file.
Must be called after adding all features via addFeature().
Result QgsKernelDensityEstimation:: prepare()
Prepares the output file for writing and setups up the surface calculation.
This must be called before adding features via addFeature().
Result QgsKernelDensityEstimation:: run()
Runs the KDE calculation across the whole layer at once.
Either call this method, or manually call run(), addFeature() and finalise() separately.