QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
77  int bandNumber;
78 
80  // TODO: check if no data are excluded in stats calculation
81  qgssize elementCount;
82 
86  double maximumValue;
87 
91  double minimumValue;
92 
94  double mean;
95 
97  double range;
98 
100  double stdDev;
101 
103  int statsGathered;
104 
106  double sum;
107 
109  double sumOfSquares;
110 
112  int width;
113 
115  int height;
116 
118  QgsRectangle extent;
119 };
120 #endif
qgsrectangle.h
QgsRasterBandStats
Definition: qgsrasterbandstats.h:34
QgsRectangle
Definition: qgsrectangle.h:41
QgsRasterBandStats::extent
QgsRectangle extent
Extent used to calc statistics.
Definition: qgsrasterbandstats.h:131
QgsRasterBandStats::width
int width
Number of columns used to calc statistics.
Definition: qgsrasterbandstats.h:125
QgsRasterBandStats::Stats
Stats
Definition: qgsrasterbandstats.h:50
QgsRasterBandStats::statsGathered
int statsGathered
Collected statistics.
Definition: qgsrasterbandstats.h:116
QgsRasterBandStats::height
int height
Number of rows used to calc statistics.
Definition: qgsrasterbandstats.h:128
QgsRasterBandStats::bandNumber
int bandNumber
The gdal band number (starts at 1)
Definition: qgsrasterbandstats.h:90
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:723