Hi all,
I noticed strange behavior of the QgsRasterNuller when saving paletted
singleband raster to GeoTiff format. If input raster has no NODATA value, then
output raster will have NODATA value set to 0, even if such values
are not defined in the QgsRasterNuller.
Not sure is this bug or maybe I'm doing something wrong. Tested with
landcover.img layer from QGIS test dataset [0]. Here is my code
from qgis.core import *
outPath = '/tmp/test.tif'
layer = iface.mapCanvas().currentLayer()
provider = layer.dataProvider()
writer = QgsRasterFileWriter(outPath)
writer.setOutputFormat('GTiff')
pipe = QgsRasterPipe()
if not pipe.set(provider.clone()):
print 'Cannot set pipe provider'
nuller = QgsRasterNuller()
for band in xrange(1, provider.bandCount() + 1):
nuller.setNoData(band, [])
if not pipe.insert(1, nuller):
print 'Cannot set pipe nuller'
projector = QgsRasterProjector()
projector.setCRS(layer.crs(), layer.crs())
if not pipe.insert(2, projector):
print 'Cannot set pipe projector'
writer.writeRaster(pipe, layer.width(), layer.height(),
layer.extent(), layer.crs())
result = QgsRasterLayer(outPath, 'converted', 'gdal')
QgsMapLayerRegistry.instance().addMapLayer(result)
Any ideas what is wrong?
[0] http://qgis.org/downloads/data/qgis_sample_data.zip
Thanks
--
Alexander Bruy
_______________________________________________
Qgis-developer mailing list
[email protected]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer