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
-
1What 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– Michael Stimson2019年07月02日 00:26:41 +00:00Commented Jul 2, 2019 at 0:26
-
i’ve decided to skip the translate and produce contours from my vrt, is this acceptable?Jesse Warren– Jesse Warren2019年07月02日 01:04:23 +00:00Commented Jul 2, 2019 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– Michael Stimson2019年07月02日 01:21:19 +00:00Commented Jul 2, 2019 at 1:21
-
2Why are you doing Python imports in your shell script? Is that some error of formatting in your question?alphabetasoup– alphabetasoup2019年07月02日 01:41:28 +00:00Commented Jul 2, 2019 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 arcpyJesse Warren– Jesse Warren2019年07月02日 01:42:30 +00:00Commented Jul 2, 2019 at 1:42
1 Answer 1
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