On Tue, Apr 28, 2015 at 1:23 PM, Torsten Lange <[email protected]> wrote: > > Hello, > > I would like to batch-write some raster files from a project to one common > folder using a script. This is my function: > > def writeRaster(rasterObj, pathToFile, cols, rows, rasterExtentObj, > rasterCRSObj): > provider = myRaster.dataProvider() > pipe = QgsRasterPipe() > pipe.set(provider.clone()) > file_writer = QgsRasterFileWriter(pathToFile) > file_writer.writeRaster(pipe, cols, rows, rasterExtentObj, rasterCRSObj)
If you set on the pipe only the provider, you get 'raw' data, you need to clone the whole layer's pipe pipe = QgsRasterPipe( rasterLayer.pipe() ) see https://github.com/qgis/QGIS/blob/final-2_8_0/src/app/qgisapp.cpp#L5077 Radim > (Its a slightly modified example I found at nullege.com.) > > For normal rasters this works just fine, but not for maps (scanned and > georeferenced). The map colors are recoded to grey-values, as one could > expect. Is there a way to keep the colors? From what I have seen, there is > no parameter to handle this in a QgsRasterPipe(). > > Also, I remember once I tried to create a virtual raster cataloge using > these maps. That failed because the maps used different color palettes. I > guess they should be in RGB to create the vrt cataloge, shouldn't they? > > Thanks for suggestions, Torsten > > > _______________________________________________ > Qgis-user mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/qgis-user _______________________________________________ Qgis-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-user
