Skip to content

Commit b9ae061

Browse files
committed
add raster stats to python bindings (many more functions missing)
1 parent 126932f commit b9ae061

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

python/core/qgsrasterdataprovider.sip

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,32 @@ class QgsRasterDataProvider : QgsDataProvider
7979

8080
// TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box
8181

82-
83-
/**
82+
// TODO: add other missing bindings (histo, pyramids and others)
83+
84+
/** If the provider supports it, return band stats for the
85+
given band. Default behaviour is to blockwise read the data
86+
and generate the stats unless the provider overloads this function. */
87+
//virtual QgsRasterBandStats bandStatistics( int theBandNo );
88+
89+
/** \brief Get band statistics.
90+
* @param theBandNo The band (number).
91+
* @param theStats Requested statistics
92+
* @param theExtent Extent used to calc histogram, if empty, whole raster extent is used.
93+
* @param theSampleSize Approximate number of cells in sample. If 0, all cells (whole raster will be used). If raster does not have exact size (WCS without exact size for example), provider decides size of sample.
94+
* @return Band statistics.
95+
*/
96+
virtual QgsRasterBandStats bandStatistics( int theBandNo,
97+
int theStats = QgsRasterBandStats::All,
98+
const QgsRectangle & theExtent = QgsRectangle(),
99+
int theSampleSize = 0 );
100+
101+
/** \brief Returns true if histogram is available (cached, already calculated), the parameters are the same as in histogram() */
102+
virtual bool hasStatistics( int theBandNo,
103+
int theStats = QgsRasterBandStats::All,
104+
const QgsRectangle & theExtent = QgsRectangle(),
105+
int theSampleSize = 0 );
106+
107+
/**
84108
* Get metadata in a format suitable for feeding directly
85109
* into a subset of the GUI raster properties "Metadata" tab.
86110
*/

python/core/qgsrasterlayer.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public:
9696
/** \brief A list containing one RasterBandStats struct per raster band in this raster layer.
9797
* Note that while every RasterBandStats element will have the name and number of its associated
9898
* band populated, any additional stats are calculated on a need to know basis.*/
99-
typedef QList<QgsRasterBandStats> RasterStatsList;
99+
// typedef QList<QgsRasterBandStats> RasterStatsList;
100100

101101

102102

0 commit comments

Comments
 (0)