QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsrasterbandstats.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterbandstats.h - description
3  -------------------
4  begin : Fri Jun 28 2002
5  copyright : (C) 2005 by T.Sutton
6  email : [email protected]
7 ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSRASTERBANDSTATS
19 #define QGSRASTERBANDSTATS
20 
21 #include "qgis_core.h"
22 #include <QString>
23 #include <QVector>
24 
25 #include <limits>
26 
27 #include "qgsrectangle.h"
28 
34 class CORE_EXPORT QgsRasterBandStats
35 {
36  public:
37  enum Stats
38  {
39  None = 0,
40  Min = 1,
41  Max = 1 << 1,
42  Range = 1 << 2,
43  Sum = 1 << 3,
44  Mean = 1 << 4,
45  StdDev = 1 << 5,
46  SumOfSquares = 1 << 6,
47  All = Min | Max | Range | Sum | Mean | StdDev | SumOfSquares
48  };
49 
51  {
52  statsGathered = None;
53  minimumValue = std::numeric_limits<double>::max();
54  maximumValue = -std::numeric_limits<double>::max();
55  range = 0.0;
56  mean = 0.0;
57  sumOfSquares = 0.0;
58  stdDev = 0.0;
59  sum = 0.0;
60  elementCount = 0;
61  width = 0;
62  height = 0;
63  bandNumber = 1;
64  }
65 
67  bool contains( const QgsRasterBandStats &s ) const
68  {
69  return ( s.bandNumber == bandNumber &&
70  s.extent == extent &&
71  s.width == width &&
72  s.height == height &&
73  s.statsGathered == ( statsGathered & s.statsGathered ) );
74  }
75 
78 
79  // TODO: check if no data are excluded in stats calculation
80 
83 
88  double maximumValue;
89 
94  double minimumValue;
95 
97  double mean;
98 
100  double range;
101 
103  double stdDev;
104 
107 
109  double sum;
110 
112  double sumOfSquares;
113 
115  int width;
116 
118  int height;
119 
122 };
123 #endif
QgsRasterBandStats::elementCount
qgssize elementCount
The number of not no data cells in the band.
Definition: qgsrasterbandstats.h:82
qgsrectangle.h
QgsRasterBandStats
The RasterBandStats struct is a container for statistics about a single raster band.
Definition: qgsrasterbandstats.h:35
QgsRasterBandStats::sumOfSquares
double sumOfSquares
The sum of the squares. Used to calculate standard deviation.
Definition: qgsrasterbandstats.h:112
QgsRasterBandStats::mean
double mean
The mean cell value for the band. NO_DATA values are excluded.
Definition: qgsrasterbandstats.h:97
QgsRasterBandStats::range
double range
The range is the distance between min & max.
Definition: qgsrasterbandstats.h:100
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsRasterBandStats::maximumValue
double maximumValue
The maximum cell value in the raster band.
Definition: qgsrasterbandstats.h:88
QgsRasterBandStats::contains
bool contains(const QgsRasterBandStats &s) const
Compares region, size etc. not collected statistics.
Definition: qgsrasterbandstats.h:67
QgsRasterBandStats::QgsRasterBandStats
QgsRasterBandStats()
Definition: qgsrasterbandstats.h:50
QgsRasterBandStats::sum
double sum
The sum of all cells in the band. NO_DATA values are excluded.
Definition: qgsrasterbandstats.h:109
QgsRasterBandStats::minimumValue
double minimumValue
The minimum cell value in the raster band.
Definition: qgsrasterbandstats.h:94
QgsRasterBandStats::extent
QgsRectangle extent
Extent used to calc statistics.
Definition: qgsrasterbandstats.h:121
QgsRasterBandStats::width
int width
Number of columns used to calc statistics.
Definition: qgsrasterbandstats.h:115
QgsRasterBandStats::stdDev
double stdDev
The standard deviation of the cell values.
Definition: qgsrasterbandstats.h:103
QgsRasterBandStats::Stats
Stats
Definition: qgsrasterbandstats.h:38
QgsRasterBandStats::statsGathered
int statsGathered
Collected statistics.
Definition: qgsrasterbandstats.h:106
QgsRasterBandStats::height
int height
Number of rows used to calc statistics.
Definition: qgsrasterbandstats.h:118
QgsRasterBandStats::bandNumber
int bandNumber
The gdal band number (starts at 1)
Definition: qgsrasterbandstats.h:77
qgssize
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
Definition: qgis.h:768