1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

batch saving 10m DTM layers using python console

Discussion in 'Geography' started by David Laverty, Oct 8, 2018.

  1. I am attempting to batch save 300 10m DTM tiles all in the same Raster type 'Float 32-bit' for using to create a VRT. At present I cannot create a VRT using the original Raster layers as some of the Tiles cannot be converted due to various reasons Such as the postive NS resolution, some saved as VRT's already and others 'Float 64-bit' meaning it will not create a full VRT of these type combinations for whatever reason.

    I have been able to create and save the full 300 tiles using the following python code in the console which I have gathered from this site in another question

    myDir = "C:\Users\MY_DIR\" layers = iface.legendInterface().layers() pipe = QgsRasterPipe() for layer in layers: extent = layer.extent() width, height = layer.width(), layer.GetRasterBand(1) renderer = layer.renderer() provider=layer.dataProvider() crs = layer.crs().toWkt() pipe.set(provider.clone()) pipe.set(renderer.clone()) file_writer = QgsRasterFileWriter(myDir + layer.name() + ".tif") file_writer.writeRaster(pipe, width, height, extent, layer.crs())

    The problem is that once created in my directory folder, the .tif's created have got 4 raster bands and the heights of my Terrain are all lower than what the original raster is. Is there something I could add to this code that would allow me to keep the original Band one values of the raster corresponding to the true height of the terrain?

    Login To add answer/comment
     

Share This Page