QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
79  // TODO: check if no data are excluded in stats calculation
80 
82  qgssize elementCount;
83 
88  double maximumValue;
89 
94  double minimumValue;
95 
97  double mean;
98 
100  double range;
101 
103  double stdDev;
104 
106  int statsGathered;
107 
109  double sum;
110 
112  double sumOfSquares;
113 
115  int width;
116 
118  int height;
119 
121  QgsRectangle extent;
122 };
123 #endif
qgsrectangle.h
QgsRasterBandStats
The RasterBandStats struct is a container for statistics about a single raster band.
Definition: qgsrasterbandstats.h:34
Direction::None
@ None
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsRasterBandStats::extent
QgsRectangle extent
Extent used to calc statistics.
Definition: qgsrasterbandstats.h:134
QgsRasterBandStats::width
int width
Number of columns used to calc statistics.
Definition: qgsrasterbandstats.h:128
QgsRasterBandStats::Stats
Stats
Definition: qgsrasterbandstats.h:50
QgsRasterBandStats::statsGathered
int statsGathered
Collected statistics.
Definition: qgsrasterbandstats.h:119
QgsRasterBandStats::height
int height
Number of rows used to calc statistics.
Definition: qgsrasterbandstats.h:131
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:2791