3

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

  • 1
    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
  • 2
    Why are you doing Python imports in your shell script? Is that some error of formatting in your question? – alphabetasoup 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
0

QGIS can read BIL files. And you can merge the individual files using Processing Algorithms via Python without using GDAL directly.

  • Load individual files in QGIS (bulk drag/drop)
  • Open Python Console
  • Call the processing algorithm gdal:merge via processing.run()

A very similar example is at http://www.qgistutorials.com/en/docs/3/processing_algorithms_pyqgis.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.