QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsrasterdataprovider.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterdataprovider.cpp - DataProvider Interface for raster layers
3  --------------------------------------
4  Date : Mar 11, 2005
5  Copyright : (C) 2005 by Brendan Morley
6  email : morb at ozemail dot com dot au
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 #include "qgsproviderregistry.h"
19 #include "qgsrasterdataprovider.h"
21 #include "qgsprovidermetadata.h"
22 #include "qgsrasterprojector.h"
23 #include "qgslogger.h"
24 #include "qgsapplication.h"
25 
26 #include <QTime>
27 #include <QMap>
28 #include <QByteArray>
29 #include <QVariant>
30 
31 #define ERR(message) QgsError(message, "Raster provider")
32 
34 {
35  if ( mUseSrcNoDataValue.size() < bandNo )
36  {
37  for ( int i = mUseSrcNoDataValue.size(); i < bandNo; i++ )
38  {
39  mUseSrcNoDataValue.append( false );
40  }
41  }
42  mUseSrcNoDataValue[bandNo - 1] = use;
43 }
44 
45 QgsRasterBlock *QgsRasterDataProvider::block( int bandNo, QgsRectangle const &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback )
46 {
47  QgsDebugMsgLevel( QStringLiteral( "bandNo = %1 width = %2 height = %3" ).arg( bandNo ).arg( width ).arg( height ), 4 );
48  QgsDebugMsgLevel( QStringLiteral( "boundingBox = %1" ).arg( boundingBox.toString() ), 4 );
49 
50  std::unique_ptr< QgsRasterBlock > block = qgis::make_unique< QgsRasterBlock >( dataType( bandNo ), width, height );
51  if ( sourceHasNoDataValue( bandNo ) && useSourceNoDataValue( bandNo ) )
52  {
53  block->setNoDataValue( sourceNoDataValue( bandNo ) );
54  }
55 
56  if ( block->isEmpty() )
57  {
58  QgsDebugMsg( QStringLiteral( "Couldn't create raster block" ) );
59  return block.release();
60  }
61 
62  // Read necessary extent only
63  QgsRectangle tmpExtent = boundingBox;
64 
65  if ( tmpExtent.isEmpty() )
66  {
67  QgsDebugMsg( QStringLiteral( "Extent outside provider extent" ) );
68  block->setIsNoData();
69  return block.release();
70  }
71 
72  double xRes = boundingBox.width() / width;
73  double yRes = boundingBox.height() / height;
74  double tmpXRes, tmpYRes;
75  double providerXRes = 0;
76  double providerYRes = 0;
77  if ( capabilities() & Size )
78  {
79  providerXRes = extent().width() / xSize();
80  providerYRes = extent().height() / ySize();
81  tmpXRes = std::max( providerXRes, xRes );
82  tmpYRes = std::max( providerYRes, yRes );
83  if ( qgsDoubleNear( tmpXRes, xRes ) ) tmpXRes = xRes;
84  if ( qgsDoubleNear( tmpYRes, yRes ) ) tmpYRes = yRes;
85  }
86  else
87  {
88  tmpXRes = xRes;
89  tmpYRes = yRes;
90  }
91 
92  if ( tmpExtent != boundingBox ||
93  tmpXRes > xRes || tmpYRes > yRes )
94  {
95  // Read smaller extent or lower resolution
96 
97  if ( !extent().contains( boundingBox ) )
98  {
99  QRect subRect = QgsRasterBlock::subRect( boundingBox, width, height, extent() );
100  block->setIsNoDataExcept( subRect );
101  }
102 
103  // Calculate row/col limits (before tmpExtent is aligned)
104  int fromRow = std::round( ( boundingBox.yMaximum() - tmpExtent.yMaximum() ) / yRes );
105  int toRow = std::round( ( boundingBox.yMaximum() - tmpExtent.yMinimum() ) / yRes ) - 1;
106  int fromCol = std::round( ( tmpExtent.xMinimum() - boundingBox.xMinimum() ) / xRes );
107  int toCol = std::round( ( tmpExtent.xMaximum() - boundingBox.xMinimum() ) / xRes ) - 1;
108 
109  QgsDebugMsgLevel( QStringLiteral( "fromRow = %1 toRow = %2 fromCol = %3 toCol = %4" ).arg( fromRow ).arg( toRow ).arg( fromCol ).arg( toCol ), 4 );
110 
111  if ( fromRow < 0 || fromRow >= height || toRow < 0 || toRow >= height ||
112  fromCol < 0 || fromCol >= width || toCol < 0 || toCol >= width )
113  {
114  // Should not happen
115  QgsDebugMsg( QStringLiteral( "Row or column limits out of range" ) );
116  return block.release();
117  }
118 
119  // If lower source resolution is used, the extent must beS aligned to original
120  // resolution to avoid possible shift due to resampling
121  if ( tmpXRes > xRes )
122  {
123  int col = std::floor( ( tmpExtent.xMinimum() - extent().xMinimum() ) / providerXRes );
124  tmpExtent.setXMinimum( extent().xMinimum() + col * providerXRes );
125  col = std::ceil( ( tmpExtent.xMaximum() - extent().xMinimum() ) / providerXRes );
126  tmpExtent.setXMaximum( extent().xMinimum() + col * providerXRes );
127  }
128  if ( tmpYRes > yRes )
129  {
130  int row = std::floor( ( extent().yMaximum() - tmpExtent.yMaximum() ) / providerYRes );
131  tmpExtent.setYMaximum( extent().yMaximum() - row * providerYRes );
132  row = std::ceil( ( extent().yMaximum() - tmpExtent.yMinimum() ) / providerYRes );
133  tmpExtent.setYMinimum( extent().yMaximum() - row * providerYRes );
134  }
135  int tmpWidth = std::round( tmpExtent.width() / tmpXRes );
136  int tmpHeight = std::round( tmpExtent.height() / tmpYRes );
137  tmpXRes = tmpExtent.width() / tmpWidth;
138  tmpYRes = tmpExtent.height() / tmpHeight;
139 
140  QgsDebugMsgLevel( QStringLiteral( "Reading smaller block tmpWidth = %1 height = %2" ).arg( tmpWidth ).arg( tmpHeight ), 4 );
141  QgsDebugMsgLevel( QStringLiteral( "tmpExtent = %1" ).arg( tmpExtent.toString() ), 4 );
142 
143  std::unique_ptr< QgsRasterBlock > tmpBlock = qgis::make_unique< QgsRasterBlock >( dataType( bandNo ), tmpWidth, tmpHeight );
144  if ( sourceHasNoDataValue( bandNo ) && useSourceNoDataValue( bandNo ) )
145  {
146  tmpBlock->setNoDataValue( sourceNoDataValue( bandNo ) );
147  }
148 
149  if ( !readBlock( bandNo, tmpExtent, tmpWidth, tmpHeight, tmpBlock->bits(), feedback ) )
150  {
151  QgsDebugMsg( QStringLiteral( "Error occurred while reading block" ) );
152  block->setIsNoData();
153  return block.release();
154  }
155 
156  int pixelSize = dataTypeSize( bandNo );
157 
158  double xMin = boundingBox.xMinimum();
159  double yMax = boundingBox.yMaximum();
160  double tmpXMin = tmpExtent.xMinimum();
161  double tmpYMax = tmpExtent.yMaximum();
162 
163  for ( int row = fromRow; row <= toRow; row++ )
164  {
165  double y = yMax - ( row + 0.5 ) * yRes;
166  int tmpRow = std::floor( ( tmpYMax - y ) / tmpYRes );
167 
168  for ( int col = fromCol; col <= toCol; col++ )
169  {
170  double x = xMin + ( col + 0.5 ) * xRes;
171  int tmpCol = std::floor( ( x - tmpXMin ) / tmpXRes );
172 
173  if ( tmpRow < 0 || tmpRow >= tmpHeight || tmpCol < 0 || tmpCol >= tmpWidth )
174  {
175  QgsDebugMsg( QStringLiteral( "Source row or column limits out of range" ) );
176  block->setIsNoData(); // so that the problem becomes obvious and fixed
177  return block.release();
178  }
179 
180  qgssize tmpIndex = static_cast< qgssize >( tmpRow ) * static_cast< qgssize >( tmpWidth ) + tmpCol;
181  qgssize index = row * static_cast< qgssize >( width ) + col;
182 
183  char *tmpBits = tmpBlock->bits( tmpIndex );
184  char *bits = block->bits( index );
185  if ( !tmpBits )
186  {
187  QgsDebugMsg( QStringLiteral( "Cannot get input block data tmpRow = %1 tmpCol = %2 tmpIndex = %3." ).arg( tmpRow ).arg( tmpCol ).arg( tmpIndex ) );
188  continue;
189  }
190  if ( !bits )
191  {
192  QgsDebugMsg( QStringLiteral( "Cannot set output block data." ) );
193  continue;
194  }
195  memcpy( bits, tmpBits, pixelSize );
196  }
197  }
198  }
199  else
200  {
201  if ( !readBlock( bandNo, boundingBox, width, height, block->bits(), feedback ) )
202  {
203  QgsDebugMsg( QStringLiteral( "Error occurred while reading block" ) );
204  block->setIsNoData();
205  return block.release();
206  }
207  }
208 
209  // apply scale and offset
210  block->applyScaleOffset( bandScale( bandNo ), bandOffset( bandNo ) );
211  // apply user no data values
212  block->applyNoDataValues( userNoDataValues( bandNo ) );
213  return block.release();
214 }
215 
218  , QgsRasterInterface( nullptr )
219 {
220 }
221 
223  : QgsDataProvider( uri, options )
224  , QgsRasterInterface( nullptr )
225 {
226 }
227 
228 QgsRasterDataProvider::ProviderCapabilities QgsRasterDataProvider::providerCapabilities() const
229 {
231 }
232 
233 //
234 //Random Static convenience function
235 //
237 // convenience function for building metadata() HTML table cells
238 
240 {
241  QString s;
242  return s;
243 }
244 
245 // Default implementation for values
246 QgsRasterIdentifyResult QgsRasterDataProvider::identify( const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox, int width, int height, int /*dpi*/ )
247 {
248  QgsDebugMsgLevel( QStringLiteral( "Entered" ), 4 );
249  QMap<int, QVariant> results;
250 
251  if ( format != QgsRaster::IdentifyFormatValue || !( capabilities() & IdentifyValue ) )
252  {
253  QgsDebugMsg( QStringLiteral( "Format not supported" ) );
254  return QgsRasterIdentifyResult( ERR( tr( "Format not supported" ) ) );
255  }
256 
257  if ( !extent().contains( point ) )
258  {
259  // Outside the raster
260  for ( int bandNo = 1; bandNo <= bandCount(); bandNo++ )
261  {
262  results.insert( bandNo, QVariant() );
263  }
265  }
266 
267  QgsRectangle finalExtent = boundingBox;
268  if ( finalExtent.isEmpty() )
269  finalExtent = extent();
270 
271  if ( width == 0 )
272  {
273  width = capabilities() & Size ? xSize() : 1000;
274  }
275  if ( height == 0 )
276  {
277  height = capabilities() & Size ? ySize() : 1000;
278  }
279 
280  // Calculate the row / column where the point falls
281  double xres = ( finalExtent.width() ) / width;
282  double yres = ( finalExtent.height() ) / height;
283 
284  int col = static_cast< int >( std::floor( ( point.x() - finalExtent.xMinimum() ) / xres ) );
285  int row = static_cast< int >( std::floor( ( finalExtent.yMaximum() - point.y() ) / yres ) );
286 
287  double xMin = finalExtent.xMinimum() + col * xres;
288  double xMax = xMin + xres;
289  double yMax = finalExtent.yMaximum() - row * yres;
290  double yMin = yMax - yres;
291  QgsRectangle pixelExtent( xMin, yMin, xMax, yMax );
292 
293  for ( int i = 1; i <= bandCount(); i++ )
294  {
295  std::unique_ptr< QgsRasterBlock > bandBlock( block( i, pixelExtent, 1, 1 ) );
296 
297  if ( bandBlock )
298  {
299  double value = bandBlock->value( 0 );
300 
301  results.insert( i, value );
302  }
303  else
304  {
305  results.insert( i, QVariant() );
306  }
307  }
309 }
310 
311 double QgsRasterDataProvider::sample( const QgsPointXY &point, int band,
312  bool *ok, const QgsRectangle &boundingBox, int width, int height, int dpi )
313 {
314  if ( ok )
315  *ok = false;
316 
317  const auto res = identify( point, QgsRaster::IdentifyFormatValue, boundingBox, width, height, dpi );
318  const QVariant value = res.results().value( band );
319 
320  if ( !value.isValid() )
321  return std::numeric_limits<double>::quiet_NaN();
322 
323  if ( ok )
324  *ok = true;
325 
326  return value.toDouble( ok );
327 }
328 
330 {
331  return QStringLiteral( "text/plain" );
332 }
333 
334 bool QgsRasterDataProvider::writeBlock( QgsRasterBlock *block, int band, int xOffset, int yOffset )
335 {
336  if ( !block )
337  return false;
338  if ( !isEditable() )
339  {
340  QgsDebugMsg( QStringLiteral( "writeBlock() called on read-only provider." ) );
341  return false;
342  }
343  return write( block->bits(), band, block->width(), block->height(), xOffset, yOffset );
344 }
345 
346 // typedef QList<QPair<QString, QString> > *pyramidResamplingMethods_t();
347 QList<QPair<QString, QString> > QgsRasterDataProvider::pyramidResamplingMethods( const QString &providerKey )
348 {
349  QList<QPair<QString, QString> > methods = QgsProviderRegistry::instance()->pyramidResamplingMethods( providerKey );
350  if ( methods.isEmpty() )
351  {
352  QgsDebugMsg( QStringLiteral( "provider pyramidResamplingMethods returned no methods" ) );
353  }
354  return methods;
355 }
356 
358 {
359  QList<QgsRasterPyramid> myPyramidList = buildPyramidList();
360 
361  if ( myPyramidList.isEmpty() )
362  return false;
363 
364  QList<QgsRasterPyramid>::iterator myRasterPyramidIterator;
365  for ( myRasterPyramidIterator = myPyramidList.begin();
366  myRasterPyramidIterator != myPyramidList.end();
367  ++myRasterPyramidIterator )
368  {
369  if ( myRasterPyramidIterator->exists )
370  {
371  return true;
372  }
373  }
374  return false;
375 }
376 
378 {
379  if ( bandNo >= mUserNoDataValue.size() )
380  {
381  for ( int i = mUserNoDataValue.size(); i < bandNo; i++ )
382  {
384  }
385  }
386  QgsDebugMsgLevel( QStringLiteral( "set %1 band %1 no data ranges" ).arg( noData.size() ), 4 );
387 
388  if ( mUserNoDataValue[bandNo - 1] != noData )
389  {
390  // Clear statistics
391  int i = 0;
392  while ( i < mStatistics.size() )
393  {
394  if ( mStatistics.value( i ).bandNumber == bandNo )
395  {
396  mStatistics.removeAt( i );
397  mHistograms.removeAt( i );
398  }
399  else
400  {
401  i++;
402  }
403  }
404  mUserNoDataValue[bandNo - 1] = noData;
405  }
406 }
407 
408 
410  const QString &uri,
411  const QString &format, int nBands,
412  Qgis::DataType type,
413  int width, int height, double *geoTransform,
415  const QStringList &createOptions )
416 {
418  providerKey,
419  uri, format,
420  nBands, type, width,
421  height, geoTransform, crs, createOptions );
422  if ( !ret )
423  QgsDebugMsg( "Cannot resolve 'createRasterDataProviderFunction' function in " + providerKey + " provider" );
424  // TODO: it would be good to return invalid QgsRasterDataProvider
425  // with QgsError set, but QgsRasterDataProvider has pure virtual methods
426 
427  return ret;
428 }
429 
431 {
432  switch ( format )
433  {
435  return QStringLiteral( "Value" );
437  return QStringLiteral( "Text" );
439  return QStringLiteral( "Html" );
441  return QStringLiteral( "Feature" );
442  default:
443  return QStringLiteral( "Undefined" );
444  }
445 }
446 
448 {
449  switch ( format )
450  {
452  return tr( "Value" );
454  return tr( "Text" );
456  return tr( "Html" );
458  return tr( "Feature" );
459  default:
460  return QStringLiteral( "Undefined" );
461  }
462 }
463 
465 {
466  if ( formatName == QLatin1String( "Value" ) ) return QgsRaster::IdentifyFormatValue;
467  if ( formatName == QLatin1String( "Text" ) ) return QgsRaster::IdentifyFormatText;
468  if ( formatName == QLatin1String( "Html" ) ) return QgsRaster::IdentifyFormatHtml;
469  if ( formatName == QLatin1String( "Feature" ) ) return QgsRaster::IdentifyFormatFeature;
471 }
472 
474 {
475  switch ( format )
476  {
478  return IdentifyValue;
480  return IdentifyText;
482  return IdentifyHtml;
484  return IdentifyFeature;
485  default:
486  return NoCapabilities;
487  }
488 }
489 
491 {
492  return QList< double >();
493 }
494 
496 {
497  return false;
498 }
499 
500 bool QgsRasterDataProvider::userNoDataValuesContains( int bandNo, double value ) const
501 {
502  QgsRasterRangeList rangeList = mUserNoDataValue.value( bandNo - 1 );
503  return QgsRasterRange::contains( value, rangeList );
504 }
505 
507 {
508  mDpi = other.mDpi;
513  mExtent = other.mExtent;
514 }
515 
516 // ENDS
bool hasPyramids()
Returns true if raster has at least one populated histogram.
virtual int bandCount() const =0
Gets number of bands.
virtual double sample(const QgsPointXY &point, int band, bool *ok=nullptr, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Samples a raster value from the specified band found at the point position.
void setNoDataValue(double noDataValue)
Sets cell value that will be considered as "no data".
IdentifyFormat
Definition: qgsraster.h:57
A rectangle specified with double values.
Definition: qgsrectangle.h:41
void copyBaseSettings(const QgsRasterDataProvider &other)
Copy member variables from other raster data provider. Useful for implementation of clone() method in...
bool contains(double value) const
Returns true if this range contains the specified value.
virtual void setUseSourceNoDataValue(int bandNo, bool use)
Sets the source nodata value usage.
void setXMaximum(double x)
Set the maximum x value.
Definition: qgsrectangle.h:135
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
virtual double bandOffset(int bandNo) const
Read band offset for raster value.
bool userNoDataValuesContains(int bandNo, double value) const
Returns true if user no data contains value.
double y
Definition: qgspointxy.h:48
A class to represent a 2D point.
Definition: qgspointxy.h:43
virtual bool ignoreExtents() const
Returns true if the extents reported by the data provider are not reliable and it&#39;s possible that the...
int height() const
Returns the height (number of rows) of the raster block.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:280
DataType
Raster data types.
Definition: qgis.h:80
virtual int ySize() const
Capability
If you add to this, please also add to capabilitiesString()
static Capability identifyFormatToCapability(QgsRaster::IdentifyFormat format)
Abstract base class for spatial data provider implementations.
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
static QRect subRect(const QgsRectangle &extent, int width, int height, const QgsRectangle &subExtent)
For extent and width, height find rectangle covered by subextent.
static QString identifyFormatName(QgsRaster::IdentifyFormat format)
virtual QString lastErrorFormat()
Returns the format of the error text for the last error in this provider.
Raster identify results container.
int dpi() const
Returns the dpi of the output device.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Raster data container.
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:426
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Returns the raster layers pyramid list.
static QgsRaster::IdentifyFormat identifyFormatFromName(const QString &formatName)
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
QgsRectangle extent() const override=0
Returns the extent of the layer.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual QList< double > nativeResolutions() const
Returns a list of native resolutions if available, i.e.
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
void setYMinimum(double y)
Set the minimum y value.
Definition: qgsrectangle.h:140
QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns list of raster pyramid resampling methods.
QList< QgsRasterHistogram > mHistograms
List of cached histograms, all bands mixed.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
QgsDataSourceUri uri() const
Gets the data source specification.
QList< bool > mSrcHasNoDataValue
Source no data value exists.
QgsRasterDataProvider()
Provider capabilities.
virtual QgsRasterDataProvider * createRasterDataProvider(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates new instance of raster data provider.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
virtual bool sourceHasNoDataValue(int bandNo) const
Returns true if source band has no data value.
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 x
Definition: qgspointxy.h:47
virtual QString htmlMetadata()=0
Returns metadata in a format suitable for feeding directly into a subset of the GUI raster properties...
QList< double > mSrcNoDataValue
Source no data value is available and is set to be used or internal no data is available.
int width() const
Returns the width (number of columns) of the raster block.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:177
virtual bool readBlock(int bandNo, int xBlock, int yBlock, void *data)
Reads a block of raster data into data.
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:162
QgsRasterBlock * block(int bandNo, const QgsRectangle &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
Setting options for creating vector data providers.
char * bits(int row, int column)
Returns a pointer to block data.
QList< QgsRasterRange > QgsRasterRangeList
void setYMaximum(double y)
Set the maximum y value.
Definition: qgsrectangle.h:145
This class represents a coordinate reference system (CRS).
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position.
int dataTypeSize(int bandNo)
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:167
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:172
virtual bool write(void *data, int band, int width, int height, int xOffset, int yOffset)
Writes into the provider datasource.
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
QList< QgsRasterBandStats > mStatistics
List of cached statistics, all bands mixed.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
bool writeBlock(QgsRasterBlock *block, int band, int xOffset=0, int yOffset=0)
Writes pixel data from a raster block into the provider data source.
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
Feedback object tailored for raster block reading.
static QString identifyFormatLabel(QgsRaster::IdentifyFormat format)
virtual int xSize() const
Gets raster size.
#define ERR(message)
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
void setXMinimum(double x)
Set the minimum x value.
Definition: qgsrectangle.h:130
double height() const
Returns the height of the rectangle.
Definition: qgsrectangle.h:209
Base class for raster data providers.
static QgsRasterDataProvider * create(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates a new dataset with mDataSourceURI.
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0...
QList< bool > mUseSrcNoDataValue
Use source nodata value.
virtual double bandScale(int bandNo) const
Read band scale for raster value.