QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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
The RasterBandStats struct is a container for statistics about a single raster band.
qgssize elementCount
The number of not no data cells in the band.
int bandNumber
The gdal band number (starts at 1)
double sumOfSquares
The sum of the squares. Used to calculate standard deviation.
int height
Number of rows used to calc statistics.
int statsGathered
Collected statistics.
double mean
The mean cell value for the band. NO_DATA values are excluded.
QgsRectangle extent
Extent used to calc statistics.
double stdDev
The standard deviation of the cell values.
double minimumValue
The minimum cell value in the raster band.
int width
Number of columns used to calc statistics.
double sum
The sum of all cells in the band. NO_DATA values are excluded.
double maximumValue
The maximum cell value in the raster band.
double range
The range is the distance between min & max.
bool contains(const QgsRasterBandStats &s) const
Compares region, size etc. not collected statistics.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
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:2036