QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 : tim@linfiniti.com
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 <QString>
22 #include <QVector>
23 
24 #include <limits>
25 
26 #include "qgscolorrampshader.h"
27 #include "qgsrectangle.h"
28 
33 class CORE_EXPORT QgsRasterBandStats
34 {
35  public:
36  enum Stats
37  {
38  None = 0,
39  Min = 1,
40  Max = 1 << 1,
41  Range = 1 << 2,
42  Sum = 1 << 3,
43  Mean = 1 << 4,
44  StdDev = 1 << 5,
45  SumOfSquares = 1 << 6,
46  All = Min | Max | Range | Sum | Mean | StdDev | SumOfSquares
47  };
48 
50  {
51  statsGathered = None;
52  minimumValue = std::numeric_limits<double>::max();
53  maximumValue = -std::numeric_limits<double>::max();
54  range = 0.0;
55  mean = 0.0;
56  sumOfSquares = 0.0;
57  stdDev = 0.0;
58  sum = 0.0;
59  elementCount = 0;
60  width = 0;
61  height = 0;
62  }
63 
65  bool contains( const QgsRasterBandStats &s ) const
66  {
67  return ( s.bandNumber == bandNumber &&
68  s.extent == extent &&
69  s.width == width &&
70  s.height == height &&
71  s.statsGathered == ( statsGathered & s.statsGathered ) );
72  }
73 
76 
78  // TODO: check if no data are excluded in stats calculation
80 
83  double maximumValue;
84 
87  double minimumValue;
88 
90  double mean;
91 
93  double range;
94 
96  double stdDev;
97 
100 
102  double sum;
103 
105  double sumOfSquares;
106 
108  int width;
109 
111  int height;
112 
115 };
116 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:35
double sum
The sum of all cells in the band.
Definition: qgsrasterbandstats.h:102
int height
Number of rows used to calc statistics.
Definition: qgsrasterbandstats.h:111
int bandNumber
The gdal band number (starts at 1)
Definition: qgsrasterbandstats.h:75
double maximumValue
The maximum cell value in the raster band.
Definition: qgsrasterbandstats.h:83
Stats
Definition: qgsrasterbandstats.h:36
bool contains(const QgsRasterBandStats &s) const
Definition: qgsrasterbandstats.h:65
QgsRectangle extent
Extent used to calc statistics.
Definition: qgsrasterbandstats.h:114
double stdDev
The standard deviation of the cell values.
Definition: qgsrasterbandstats.h:96
The RasterBandStats struct is a container for statistics about a single raster band.
Definition: qgsrasterbandstats.h:33
double mean
The mean cell value for the band.
Definition: qgsrasterbandstats.h:90
qgssize elementCount
The number of not no data cells in the band.
Definition: qgsrasterbandstats.h:79
int statsGathered
Collected statistics.
Definition: qgsrasterbandstats.h:99
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:424
double range
The range is the distance between min & max.
Definition: qgsrasterbandstats.h:93
QgsRasterBandStats()
Definition: qgsrasterbandstats.h:49
double minimumValue
The minimum cell value in the raster band.
Definition: qgsrasterbandstats.h:87
int max(int a, int b)
Definition: util.h:87
double sumOfSquares
The sum of the squares.
Definition: qgsrasterbandstats.h:105
int width
Number of columns used to calc statistics.
Definition: qgsrasterbandstats.h:108