PyQGIS将栅格另存为渲染图像,然后在其上使用GDAL工具
我尝试使用QGis的“将栅格保存为渲染图像”中的代码。i是栅格图层: pipelayer = i pipeextent = pipelayer.extent() pipewidth, pipeheight = (pipelayer.width(), pipelayer.height()) piperenderer = pipelayer.renderer() pipeprovider = pipelayer.dataProvider() crs = pipelayer.crs().toWkt() pipe = QgsRasterPipe() pipe.set(pipeprovider.clone()) pipe.set(piperenderer.clone()) pipedFile = os.path.join(tempfile.gettempdir(), safeLayerName + '_pipe.tif') print pipedFile file_writer = QgsRasterFileWriter(pipedFile) file_writer.writeRaster(pipe, pipewidth, pipeheight, pipeextent, pipelayer.crs()) in_raster = pipedFile prov_raster = os.path.join(tempfile.gettempdir(), 'json_' + …