18#ifndef QGSZONALSTATISTICS_H
19#define QGSZONALSTATISTICS_H
24#include "qgis_analysis.h"
91 double rasterUnitsPerPixelX,
92 double rasterUnitsPerPixelY,
93 const QString &attributePrefix = QString(),
143 static QMap<int, QVariant> calculateStatisticsInt(
154 FeatureStats(
bool storeValues =
false,
bool storeValueCounts =
false )
155 : mStoreValues( storeValues )
156 , mStoreValueCounts( storeValueCounts )
163 max = std::numeric_limits<double>::lowest();
164 min = std::numeric_limits<double>::max();
169 void addValue(
double value,
const QgsPointXY &point,
double weight = 1.0 )
173 sum += value * weight;
191 if ( mStoreValueCounts )
192 valueCount.insert( value, valueCount.value( value, 0 ) + 1 );
194 values.append( value );
198 double max = std::numeric_limits<double>::lowest();
199 double min = std::numeric_limits<double>::max();
202 QMap<double, int> valueCount;
203 QList<double> values;
206 bool mStoreValues =
false;
207 bool mStoreValueCounts =
false;
210 QString getUniqueFieldName(
const QString &fieldName,
const QList<QgsField> &newFields );
215 double mCellSizeX = 0;
216 double mCellSizeY = 0;
221 QString mAttributePrefix;
ZonalStatistic
Statistics to be calculated during a zonal statistics operation.
@ Default
Default statistics.
@ All
All statistics. For QGIS 3.x this includes ONLY numeric statistics, but for 4.0 this will be extended...
ZonalStatisticResult
Zonal statistics result codes.
QFlags< ZonalStatistic > ZonalStatistics
Statistics to be calculated during a zonal statistics operation.
Represents a coordinate reference system (CRS).
An interface for objects which accept features via addFeature(s) methods.
An interface for objects which provide features via a getFeatures method.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Encapsulate a field in an attribute table or data source.
A geometry is the spatial representation of a feature.
Base class for raster data providers.
Base class for processing filters like renderers, reprojector, resampler etc.
Represents a raster layer.
A rectangle specified with double values.
Represents a vector layer which manages a vector based dataset.
QgsZonalStatistics(QgsVectorLayer *polygonLayer, QgsRasterLayer *rasterLayer, const QString &attributePrefix=QString(), int rasterBand=1, Qgis::ZonalStatistics stats=Qgis::ZonalStatistic::Default)
Convenience constructor for QgsZonalStatistics, using an input raster layer.
Qgis::ZonalStatisticResult calculateStatistics(QgsFeedback *feedback)
Runs the calculation.
static QString displayName(Qgis::ZonalStatistic statistic)
Returns the friendly display name for a statistic.
static QString shortName(Qgis::ZonalStatistic statistic)
Returns a short, friendly display name for a statistic, suitable for use in a field name.