# Merging many rasters with Python script within QGIS using GDAL?

I have many rasters that im trying to combine in order to produce contours. They are in the .bil format so I understand that i need to translate them using gdal first but none of my attempts have worked.

I have tried to used gdal_translate and gdal_merge with no success.

import os
import sys
import gdal
chdir C:\Users\jeswa\Desktop\GAL
SDKShell.bat
chdir C:\Users\jeswa\Desktop\TESTY
dir /s/b *.bil >listbil.txt
gdalbuildvrt -input_file_list listbil.txt testscript.vrt
#error does not like N34025raster but passes 44 and 45
gdal_translate -of GTiff C:\Users\jeswa\Desktop\TESTY\testscript.vrt C:/Users/jeswa/Desktop/TESTY/VIRTUALTIFF.tif
#no such thing as gdal_translate apparently


• What error messages are you getting? What is the value of your %PATH% after SDKShell? I use a very similar process to this and it works well; you could try CD c:\your\path\to\GDAL\bin so you can (hopefully) find translate. – Michael Stimson Jul 2 at 0:26
• i’ve decided to skip the translate and produce contours from my vrt, is this acceptable? – Jesse Warren Jul 2 at 1:04
• It should be but be aware that VRT is a slower raster format than a single image file, if you can translate to GeoTIFF with no compression your contours will run much faster. – Michael Stimson Jul 2 at 1:21
• Why are you doing Python imports in your shell script? Is that some error of formatting in your question? – Richard Law Jul 2 at 1:41
• i’m not really sure how to work through QGIS python, which is a requirement, and i only really have experience with arcpy – Jesse Warren Jul 2 at 1:42