QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 
80  // TODO: check if no data are excluded in stats calculation
82 
86  double maximumValue;
87 
91  double minimumValue;
92 
94  double mean;
95 
97  double range;
98 
100  double stdDev;
101 
104 
106  double sum;
107 
109  double sumOfSquares;
110 
112  int width;
113 
115  int height;
116 
119 };
120 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:41
double sum
The sum of all cells in the band. NO_DATA values are excluded.
int height
Number of rows used to calc statistics.
int bandNumber
The gdal band number (starts at 1)
double maximumValue
The maximum cell value in the raster band.
bool contains(const QgsRasterBandStats &s) const
Compares region, size etc. not collected statistics.
QgsRectangle extent
Extent used to calc statistics.
double stdDev
The standard deviation of the cell values.
The RasterBandStats struct is a container for statistics about a single raster band.
double mean
The mean cell value for the band. NO_DATA values are excluded.
qgssize elementCount
The number of not no data cells in the band.
int statsGathered
Collected statistics.
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:621
double range
The range is the distance between min & max.
double minimumValue
The minimum cell value in the raster band.
double sumOfSquares
The sum of the squares. Used to calculate standard deviation.
int width
Number of columns used to calc statistics.