I would like to create a singleBand raster (grayScale) using the method qgis.core.QgsRasterFileWriter.writeRaster
According to the documentation:
writeRaster(self,
pipe: QgsRasterPipe,
nCols: int,
nRows: int,
outputExtent: QgsRectangle,
crs: QgsCoordinateReferenceSystem,
feedback: QgsRasterBlockFeedback = None
) → QgsRasterFileWriter.WriterError
You may be agree that this documentation is very unclear on how to use it...
I success to create vectorLayer from QgsVectorFileWriter.writeAsVectorFormat
.
But there is too few examples on internet using QgsRasterFileWriter
...
Here is the example script I have for the moment:
import os
import numpy
from qgis.core import (
QgsMapLayer,
QgsRasterFileWriter,
QgsCoordinateReferenceSystem,
QgsRectangle,
Qgis,
)
def write_to_geotiff(data: list, filename: str, epsg: str, layer: str=None) -> None:
x_data = data[0]
y_data = data[1]
z_data = data[2]
nx, ny = len(x_data), len(y_data)
##########
# CODE HERE
##########
I saw this solution to create a raster but I don t want to use GDAL because off env issues related to GDAL...