QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsrasterfilewriter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterfilewriter.h
3 ---------------------
4 begin : July 2012
5 copyright : (C) 2012 by Marco Hugentobler
6 email : marco dot hugentobler at sourcepole dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSRASTERFILEWRITER_H
16#define QGSRASTERFILEWRITER_H
17
18#include "qgis_core.h"
21
22#include <QDomDocument>
23#include <QDomElement>
24#include <QString>
25#include <QStringList>
26
29class QgsRasterPipe;
30class QgsRectangle;
33
41class CORE_EXPORT QgsRasterFileWriter
42{
43 public:
44
48 enum RasterFormatOption SIP_ENUM_BASETYPE( IntFlag )
49 {
50 SortRecommended = 1 << 1,
51 };
52 Q_DECLARE_FLAGS( RasterFormatOptions, RasterFormatOption )
53
54
57 QgsRasterFileWriter( const QString &outputUrl );
58
67 int width, int height,
68 const QgsRectangle &extent,
70
79 int width, int height,
80 const QgsRectangle &extent,
82 int nBands ) SIP_FACTORY;
83
84
95 Q_DECL_DEPRECATED Qgis::RasterFileWriterResult writeRaster( const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent,
97
109 Qgis::RasterFileWriterResult writeRaster( const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent,
111 const QgsCoordinateTransformContext &transformContext,
112 QgsRasterBlockFeedback *feedback = nullptr );
113
117 QString outputUrl() const { return mOutputUrl; }
118
126 void setOutputFormat( const QString &format ) { mOutputFormat = format; }
127
135 QString outputFormat() const { return mOutputFormat; }
136
144 void setOutputProviderKey( const QString &key ) { mOutputProviderKey = key; }
145
151 QString outputProviderKey() const { return mOutputProviderKey; }
152
161 void setTiledMode( bool t ) { mTiledMode = t; }
162
168 bool tiledMode() const { return mTiledMode; }
169
177 void setMaxTileWidth( int w ) { mMaxTileWidth = w; }
178
186 int maxTileWidth() const { return mMaxTileWidth; }
187
193 Qgis::RasterBuildPyramidOption buildPyramidsFlag() const { return mBuildPyramidsFlag; }
194
200 void setBuildPyramidsFlag( Qgis::RasterBuildPyramidOption f ) { mBuildPyramidsFlag = f; }
201
207 QList< int > pyramidsList() const { return mPyramidsList; }
208
214 void setPyramidsList( const QList< int > &list ) { mPyramidsList = list; }
215
216 QString pyramidsResampling() const { return mPyramidsResampling; }
217 void setPyramidsResampling( const QString &str ) { mPyramidsResampling = str; }
218
224 Qgis::RasterPyramidFormat pyramidsFormat() const { return mPyramidsFormat; }
225
231 void setPyramidsFormat( Qgis::RasterPyramidFormat f ) { mPyramidsFormat = f; }
232
240 void setMaxTileHeight( int h ) { mMaxTileHeight = h; }
241
249 int maxTileHeight() const { return mMaxTileHeight; }
250
251 // TODO QGIS 4.0: rename list to options to have more semantic argument name
252
260 Q_DECL_DEPRECATED void setCreateOptions( const QStringList &list ) SIP_DEPRECATED { setCreationOptions( list ); }
261
269 Q_DECL_DEPRECATED QStringList createOptions() const SIP_DEPRECATED { return creationOptions(); }
270
278 QStringList creationOptions() const { return mCreationOptions; }
279
287 void setCreationOptions( const QStringList &options ) { mCreationOptions = options; }
288
289 // TODO QGIS 4.0: rename list to options to have more semantic argument name
290
297 void setPyramidsConfigOptions( const QStringList &list ) { mPyramidsConfigOptions = list; }
298
305 QStringList pyramidsConfigOptions() const { return mPyramidsConfigOptions; }
306
308 static QString filterForDriver( const QString &driverName );
309
314 {
316 QString driverName;
317
320 };
321
331 static QList< QgsRasterFileWriter::FilterFormatDetails > supportedFiltersAndFormats( RasterFormatOptions options = SortRecommended );
332
341 static QStringList supportedFormatExtensions( RasterFormatOptions options = SortRecommended );
342
352 static QString driverForExtension( const QString &extension );
353
364 static QStringList extensionsForFormat( const QString &format );
365
366 private:
367 QgsRasterFileWriter(); //forbidden
368 Qgis::RasterFileWriterResult writeDataRaster( const QgsRasterPipe *pipe, QgsRasterIterator *iter, int nCols, int nRows, const QgsRectangle &outputExtent,
369 const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext,
370 QgsRasterBlockFeedback *feedback = nullptr );
371
372 // Helper method used by previous one
373 Qgis::RasterFileWriterResult writeDataRaster( const QgsRasterPipe *pipe,
374 QgsRasterIterator *iter,
375 int nCols, int nRows,
376 const QgsRectangle &outputExtent,
378 Qgis::DataType destDataType,
379 const QList<bool> &destHasNoDataValueList,
380 const QList<double> &destNoDataValueList,
381 QgsRasterDataProvider *destProvider,
382 QgsRasterBlockFeedback *feedback = nullptr );
383
384 Qgis::RasterFileWriterResult writeImageRaster( QgsRasterIterator *iter, int nCols, int nRows, const QgsRectangle &outputExtent,
386 QgsRasterBlockFeedback *feedback = nullptr );
387
398 void createVRT( int xSize, int ySize, const QgsCoordinateReferenceSystem &crs, double *geoTransform, Qgis::DataType type, const QList<bool> &destHasNoDataValueList, const QList<double> &destNoDataValueList );
399 //write vrt document to disk
400 bool writeVRT( const QString &file );
401 //add file entry to vrt
402 void addToVRT( const QString &filename, int band, int xSize, int ySize, int xOffset, int yOffset );
403 void buildPyramids( const QString &filename, QgsRasterDataProvider *destProviderIn = nullptr );
404
406 QgsRasterDataProvider *createPartProvider( const QgsRectangle &extent, int nCols, int iterCols, int iterRows,
407 int iterLeft, int iterTop,
408 const QString &outputUrl, int fileIndex, int nBands, Qgis::DataType type,
409 const QgsCoordinateReferenceSystem &crs );
410
422 QgsRasterDataProvider *initOutput( int nCols, int nRows,
423 const QgsCoordinateReferenceSystem &crs, double *geoTransform, int nBands,
424 Qgis::DataType type,
425 const QList<bool> &destHasNoDataValueList = QList<bool>(), const QList<double> &destNoDataValueList = QList<double>() );
426
428 void globalOutputParameters( const QgsRectangle &extent, int nCols, int &nRows, double *geoTransform, double &pixelSize );
429
430 QString partFileName( int fileIndex );
431 QString vrtFileName();
432
434 QString mOutputUrl;
435 QString mOutputProviderKey = QStringLiteral( "gdal" );
436 QString mOutputFormat = QStringLiteral( "GTiff" );
437 QStringList mCreationOptions;
439
441 bool mTiledMode = false;
442 int mMaxTileWidth = 500;
443 int mMaxTileHeight = 500;
444
445 QList< int > mPyramidsList;
446 QString mPyramidsResampling = QStringLiteral( "AVERAGE" );
449 QStringList mPyramidsConfigOptions;
450
451 QDomDocument mVRTDocument;
452 QList<QDomElement> mVRTBands;
453
454 QgsRasterBlockFeedback *mFeedback = nullptr;
455
456 const QgsRasterPipe *mPipe = nullptr;
457 const QgsRasterInterface *mInput = nullptr;
458};
459
460#endif // QGSRASTERFILEWRITER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
RasterPyramidFormat
Raster pyramid formats.
Definition qgis.h:4802
@ GeoTiff
Geotiff .ovr (external).
Definition qgis.h:4803
RasterFileWriterResult
Raster file export results.
Definition qgis.h:1642
DataType
Raster data types.
Definition qgis.h:372
RasterBuildPyramidOption
Raster pyramid building options.
Definition qgis.h:4817
RasterExportType
Raster file export types.
Definition qgis.h:1629
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Feedback object tailored for raster block reading.
Base class for raster data providers.
void setPyramidsList(const QList< int > &list)
Sets the list of pyramids which will be created for the output file.
enum RasterFormatOption SIP_ENUM_BASETYPE(IntFlag)
Options for sorting and filtering raster formats.
Q_DECL_DEPRECATED Qgis::RasterFileWriterResult writeRaster(const QgsRasterPipe *pipe, int nCols, int nRows, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &crs, QgsRasterBlockFeedback *feedback=nullptr) SIP_DEPRECATED
Write raster file.
void setPyramidsResampling(const QString &str)
int maxTileHeight() const
Returns the maximum tile height (in pixels) for tiled outputs.
static QStringList extensionsForFormat(const QString &format)
Returns a list of known file extensions for the given GDAL driver format.
void setMaxTileWidth(int w)
Sets the maximum tile width (in pixels) for tiled outputs.
void setTiledMode(bool t)
Sets whether the output should be tiled.
QStringList pyramidsConfigOptions() const
Returns the list of configuration options used when creating the pyramids for the output raster file.
static QString driverForExtension(const QString &extension)
Returns the GDAL driver name for a specified file extension.
Q_DECL_DEPRECATED QStringList createOptions() const SIP_DEPRECATED
Returns the list of data source creation options which will be used when creating the output raster f...
Qgis::RasterBuildPyramidOption buildPyramidsFlag() const
Returns the pyramid building option.
QgsRasterFileWriter(const QString &outputUrl)
Constructor for QgsRasterFileWriter, writing to the specified output URL/filename.
void setOutputProviderKey(const QString &key)
Sets the name of the data provider for the raster output.
void setMaxTileHeight(int h)
Sets the maximum tile height (in pixels) for tiled outputs.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
QString outputUrl() const
Returns the output URL (filename) for the raster.
QFlags< RasterFormatOption > RasterFormatOptions
Qgis::RasterPyramidFormat pyramidsFormat() const
Returns the raster pyramid format.
QString outputFormat() const
Returns the output format.
QString outputProviderKey() const
Returns the name of the data provider for the raster output.
QString pyramidsResampling() const
void setCreationOptions(const QStringList &options)
Sets a list of data source creation options to use when creating the output raster file.
QgsRasterDataProvider * createMultiBandRaster(Qgis::DataType dataType, int width, int height, const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs, int nBands) SIP_FACTORY
Create a raster file with given number of bands without initializing the pixel data.
QList< int > pyramidsList() const
Returns the list of pyramids which will be created for the output file.
void setPyramidsFormat(Qgis::RasterPyramidFormat f)
Sets the raster pyramid format.
QStringList creationOptions() const
Returns the list of data source creation options which will be used when creating the output raster f...
void setOutputFormat(const QString &format)
Sets the output format.
int maxTileWidth() const
Returns the maximum tile width (in pixels) for tiled outputs.
Q_DECL_DEPRECATED void setCreateOptions(const QStringList &list) SIP_DEPRECATED
Sets a list of data source creation options to use when creating the output raster file.
static QList< QgsRasterFileWriter::FilterFormatDetails > supportedFiltersAndFormats(RasterFormatOptions options=SortRecommended)
Returns a list or pairs, with format filter string as first element and GDAL format key as second ele...
bool tiledMode() const
Returns whether the output will be tiled.
void setPyramidsConfigOptions(const QStringList &list)
Sets a list of configuration options to use when creating the pyramids for the output raster file.
void setBuildPyramidsFlag(Qgis::RasterBuildPyramidOption f)
Sets the pyramid building option.
QgsRasterDataProvider * createOneBandRaster(Qgis::DataType dataType, int width, int height, const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs) SIP_FACTORY
Create a raster file with one band without initializing the pixel data.
Base class for processing filters like renderers, reprojector, resampler etc.
Iterator for sequentially processing raster cells.
Contains a pipeline of raster interfaces for sequential raster processing.
A rectangle specified with double values.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_FACTORY
Definition qgis_sip.h:84
Details of available filters and formats.
QString filterString
Filter string for file picker dialogs.