TransWikia.com

Merging many rasters with Python script within QGIS using GDAL?

Geographic Information Systems Asked by Jesse Warren on September 27, 2021

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:UsersjeswaDesktopGAL
SDKShell.bat
chdir C:UsersjeswaDesktopTESTY
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:UsersjeswaDesktopTESTYtestscript.vrt C:/Users/jeswa/Desktop/TESTY/VIRTUALTIFF.tif
#no such thing as gdal_translate apparently

One Answer

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

Answered by spatialthoughts on September 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP