mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[API] convenience API call to create empty raster file with given
number of bands. Will be useful for porting raster analysis code to use QgsRasterBlock instead of GDAL calls. Follow up ff8d91214748e0363010e263401212d0b4e0e491
This commit is contained in:
parent
90bef91d66
commit
9272dc0f7c
@ -53,6 +53,21 @@ class QgsRasterFileWriter
|
||||
:rtype: QgsRasterDataProvider
|
||||
%End
|
||||
|
||||
QgsRasterDataProvider *createRaster( Qgis::DataType dataType,
|
||||
int width, int height, const QgsRectangle &extent,
|
||||
int nBands, const QgsCoordinateReferenceSystem &crs ) /Factory/;
|
||||
%Docstring
|
||||
Create a raster file with given number of bands without initializing the pixel data.
|
||||
Returned provider may be used to initialize the raster using writeBlock() calls.
|
||||
Ownership of the returned provider is passed to the caller.
|
||||
.. note::
|
||||
|
||||
Does not work with tiled mode enabled.
|
||||
:return: Instance of data provider in editing mode (on success) or None on error.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsRasterDataProvider
|
||||
%End
|
||||
|
||||
WriterError writeRaster( const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent,
|
||||
const QgsCoordinateReferenceSystem &crs, QgsRasterBlockFeedback *feedback = 0 );
|
||||
%Docstring
|
||||
|
@ -41,6 +41,18 @@ QgsRasterDataProvider *QgsRasterFileWriter::createOneBandRaster( Qgis::DataType
|
||||
return initOutput( width, height, crs, geoTransform, 1, dataType, QList<bool>(), QList<double>() );
|
||||
}
|
||||
|
||||
QgsRasterDataProvider *QgsRasterFileWriter::createRaster( Qgis::DataType dataType, int width, int height, const QgsRectangle &extent, int nBands, const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
if ( mTiledMode )
|
||||
return nullptr; // does not make sense with tiled mode
|
||||
|
||||
double pixelSize;
|
||||
double geoTransform[6];
|
||||
globalOutputParameters( extent, width, height, geoTransform, pixelSize );
|
||||
|
||||
return initOutput( width, height, crs, geoTransform, nBands, dataType, QList<bool>(), QList<double>() );
|
||||
}
|
||||
|
||||
QgsRasterFileWriter::QgsRasterFileWriter( const QString &outputUrl )
|
||||
: mMode( Raw )
|
||||
, mOutputUrl( outputUrl )
|
||||
|
@ -67,6 +67,17 @@ class CORE_EXPORT QgsRasterFileWriter
|
||||
const QgsRectangle &extent,
|
||||
const QgsCoordinateReferenceSystem &crs ) SIP_FACTORY;
|
||||
|
||||
/** Create a raster file with given number of bands without initializing the pixel data.
|
||||
* Returned provider may be used to initialize the raster using writeBlock() calls.
|
||||
* Ownership of the returned provider is passed to the caller.
|
||||
* \note Does not work with tiled mode enabled.
|
||||
* \returns Instance of data provider in editing mode (on success) or nullptr on error.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsRasterDataProvider *createRaster( Qgis::DataType dataType,
|
||||
int width, int height, const QgsRectangle &extent,
|
||||
int nBands, const QgsCoordinateReferenceSystem &crs ) SIP_FACTORY;
|
||||
|
||||
/** Write raster file
|
||||
\param pipe raster pipe
|
||||
\param nCols number of output columns
|
||||
|
Loading…
x
Reference in New Issue
Block a user