Class: QgsRasterFileWriter¶
-
class
qgis.core.
QgsRasterFileWriter
¶ Bases:
sip.wrapper
The raster file writer which allows you to save a raster to a new file.
Methods
- rtype
QgsRaster.RasterBuildPyramids
Create a raster file with given number of bands without initializing the pixel data.
Create a raster file with one band without initializing the pixel data.
- rtype
List[str]
Returns the GDAL driver name for a specified file
extension
.Returns a list of known file extensions for the given GDAL driver
format
.Creates a filter for an GDAL driver key
- rtype
int
- rtype
int
- rtype
str
- rtype
str
Returns the output URL for the raster.
- rtype
List[str]
- rtype
QgsRaster.RasterPyramidsFormat
- rtype
List[int]
- rtype
str
- param f
- param list
- param h
- param w
- param format
- param key
- param list
- param f
- param list
- param str
- param t
Returns a list or pairs, with format filter string as first element and GDAL format key as second element.
Returns a list of file extensions for supported formats.
- rtype
bool
Write raster file
Attributes
-
CreateDatasourceError
= 3¶
-
DestProviderError
= 2¶
-
class
FilterFormatDetails
¶ Bases:
sip.wrapper
QgsRasterFileWriter.FilterFormatDetails(QgsRasterFileWriter.FilterFormatDetails)
-
driverName
¶
-
filterString
¶
-
-
Image
= 1¶
-
class
Mode
¶ Bases:
int
-
NoDataConflict
= 5¶
-
NoError
= 0¶
-
class
RasterFormatOption
¶ Bases:
int
-
class
RasterFormatOptions
¶ Bases:
sip.wrapper
QgsRasterFileWriter.RasterFormatOptions(Union[QgsRasterFileWriter.RasterFormatOptions, QgsRasterFileWriter.RasterFormatOption]) QgsRasterFileWriter.RasterFormatOptions(QgsRasterFileWriter.RasterFormatOptions)
-
Raw
= 0¶
-
SortRecommended
= 2¶
-
SourceProviderError
= 1¶
-
WriteCanceled
= 6¶
-
WriteError
= 4¶
-
class
WriterError
¶ Bases:
int
-
buildPyramidsFlag
(self) → QgsRaster.RasterBuildPyramids¶ - Return type
-
createMultiBandRaster
(self, dataType: Qgis.DataType, width: int, height: int, extent: QgsRectangle, crs: QgsCoordinateReferenceSystem, nBands: int) → QgsRasterDataProvider¶ 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.
- Return type
- Returns
Instance of data provider in editing mode (on success) or None on error.
Note
Does not work with tiled mode enabled.
New in version 3.0.
- Parameters
dataType (Qgis.DataType) –
width (int) –
height (int) –
extent (QgsRectangle) –
crs (QgsCoordinateReferenceSystem) –
nBands (int) –
-
createOneBandRaster
(self, dataType: Qgis.DataType, width: int, height: int, extent: QgsRectangle, crs: QgsCoordinateReferenceSystem) → QgsRasterDataProvider¶ Create a raster file with one band 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.
- Return type
- Returns
Instance of data provider in editing mode (on success) or None on error.
Note
Does not work with tiled mode enabled.
New in version 3.0.
- Parameters
dataType (Qgis.DataType) –
width (int) –
height (int) –
extent (QgsRectangle) –
crs (QgsCoordinateReferenceSystem) –
-
createOptions
(self) → List[str]¶ - Return type
List[str]
-
driverForExtension
(extension: str) → str¶ Returns the GDAL driver name for a specified file
extension
. E.g. the driver name for the “.tif” extension is “GTiff”. If no suitable drivers are found then an empty string is returned.Note that this method works for all GDAL drivers, including those without create support (and which are not supported by
QgsRasterFileWriter
).New in version 3.0.
- Parameters
extension (str) –
- Return type
str
-
extensionsForFormat
(format: str) → List[str]¶ Returns a list of known file extensions for the given GDAL driver
format
. E.g. returns “tif”, “tiff” for the format “GTiff”.If no matching format driver is found an empty list will be returned.
Note that this method works for all GDAL drivers, including those without create support (and which are not supported by
QgsRasterFileWriter
).New in version 3.0.
- Parameters
format (str) –
- Return type
List[str]
-
filterForDriver
(driverName: str) → str¶ Creates a filter for an GDAL driver key
- Parameters
driverName (str) –
- Return type
str
-
maxTileHeight
(self) → int¶ - Return type
int
-
maxTileWidth
(self) → int¶ - Return type
int
-
outputFormat
(self) → str¶ - Return type
str
-
outputProviderKey
(self) → str¶ - Return type
str
-
outputUrl
(self) → str¶ Returns the output URL for the raster.
New in version 3.0.
- Return type
str
-
pyramidsConfigOptions
(self) → List[str]¶ - Return type
List[str]
-
pyramidsFormat
(self) → QgsRaster.RasterPyramidsFormat¶ - Return type
-
pyramidsList
(self) → List[int]¶ - Return type
List[int]
-
pyramidsResampling
(self) → str¶ - Return type
str
-
setBuildPyramidsFlag
(self, f: QgsRaster.RasterBuildPyramids)¶ - Parameters
-
setCreateOptions
(self, list: Iterable[str])¶ - Parameters
list (Iterable[str]) –
-
setMaxTileHeight
(self, h: int)¶ - Parameters
h (int) –
-
setMaxTileWidth
(self, w: int)¶ - Parameters
w (int) –
-
setOutputFormat
(self, format: str)¶ - Parameters
format (str) –
-
setOutputProviderKey
(self, key: str)¶ - Parameters
key (str) –
-
setPyramidsConfigOptions
(self, list: Iterable[str])¶ - Parameters
list (Iterable[str]) –
-
setPyramidsFormat
(self, f: QgsRaster.RasterPyramidsFormat)¶ - Parameters
-
setPyramidsList
(self, list: Iterable[int])¶ - Parameters
list (Iterable[int]) –
-
setPyramidsResampling
(self, str: str)¶ - Parameters
str (str) –
-
setTiledMode
(self, t: bool)¶ - Parameters
t (bool) –
-
supportedFiltersAndFormats
(options: Union[QgsRasterFileWriter.RasterFormatOptions, QgsRasterFileWriter.RasterFormatOption] = QgsRasterFileWriter.SortRecommended) → object¶ Returns a list or pairs, with format filter string as first element and GDAL format key as second element. Relies on GDAL_DMD_EXTENSIONS metadata, if it is empty corresponding driver will be skipped even if supported.
The
options
argument can be used to control the sorting and filtering of returned formats.See also
- Parameters
options (Union[QgsRasterFileWriter.RasterFormatOptions) –
- Return type
object
-
supportedFormatExtensions
(options: Union[QgsRasterFileWriter.RasterFormatOptions, QgsRasterFileWriter.RasterFormatOption] = QgsRasterFileWriter.SortRecommended) → List[str]¶ Returns a list of file extensions for supported formats.
The
options
argument can be used to control the sorting and filtering of returned formats.See also
New in version 3.0.
- Parameters
options (Union[QgsRasterFileWriter.RasterFormatOptions) –
- Return type
List[str]
-
tiledMode
(self) → bool¶ - Return type
bool
-
writeRaster
(self, pipe: QgsRasterPipe, nCols: int, nRows: int, outputExtent: QgsRectangle, crs: QgsCoordinateReferenceSystem, feedback: QgsRasterBlockFeedback = None) → QgsRasterFileWriter.WriterError¶ Write raster file
- Parameters
pipe (QgsRasterPipe) – raster pipe
nCols (int) – number of output columns
nRows (int) – number of output rows (or -1 to automatically calculate row number to have square pixels)
outputExtent (QgsRectangle) – extent to output
crs (QgsCoordinateReferenceSystem) – crs to reproject to
feedback (
QgsRasterBlockFeedback
= None) – optional feedback object for progress reports
- Return type