I have multiple ASCII file that i want to convert into .iff file. They are saved in a separate file on my pc. I have also importet the all in QGis. To convert them to .tiff format i have used:

raster -> conversion -> translate -> tick "batch mode" in upper right -> select directories for input and output file -> select format ...

enter image description here

it freezes. Am i doing something wrong? The data file are not that large as to crach QGis.

  • It sounds like one of your ASCII files is corrupt, this happens from time to time, can you find out from the log if it's the same file each time? – Michael Stimson May 3 '18 at 11:09

At the risk of jumping too far ahead here is a python script that I use to convert a folder of rasters into GeoTIFF:

import os, sys

InFolder  = sys.argv[1]
OutFolder = sys.argv[2]
SRS_Code  = 28355 # MGA Zone 55, change as needed

ValidExt = [".TIF",".IMG",".BIL",".ASC"] # add more extensions here
gTran    = 'gdal_translate -of GTIFF -a_srs EPSG:{0}'.format(SRS_Code)

InFiles = os.listdir(InFolder)

ffList = []
for x in InFiles:
    fN,fE = os.path.splitext(x)
    if fE.upper() in ValidExt:

with open(os.path.join(InFolder,"Convert.bat"),'w') as BatFile:
    for x in ffList:
        fN,fE = os.path.splitext(x)
        fS = fN.split("_")
        fS[0] = fS[0].zfill(3)
        fN2 = '_'.join(fS)
        OutName = "{0}.tif".format(fN2)
        Command = "{0} {1} {2}\n".format(gTran,os.path.join(InFolder,x),os.path.join(OutFolder,OutName))

This writes a batch file in the same directory as your input which you can run and catch the error messages, hopefully finding out why gdal_translate is stopping.

If you don't like python you can do something similar in Excel:

  1. Start with dir *.asc /b /s > c:\full\path\list.txt from a command prompt, this will write a text file with the full path of all the ASC files in this folder and all subfolders.
  2. Open this text file in Excel and duplicate the column.
  3. Find and replace on the second column .asc with .tif
  4. Insert a column at the beginning.
  5. Fill the first column with gdal_translate -of GTIFF.
  6. Save as type MS Dos CSV.
  7. Rename the CSV to .bat
  8. Edit the text file in notepad and find and replace the commas with spaces.
  9. Save, exit notepad, drag the .bat file into your command window and hit enter.

After you've found the bad file have a look at it and see if you can spot the problem, if not ask another question on GIS.SE.

| improve this answer | |
  • This is exactly what i was looking for. any chance you got this for R too? :D – user1607 May 3 '18 at 11:43
  • 1
    Sorry, I don't do R.. only python, VB.net, C# and C++ currently. If you have QGIS you have python, you can use it via the console docs.qgis.org/2.18/en/docs/user_manual/plugins/… just change the values of the inputs from sys.argv (arguments) to a full path (copy/paste from Explorer but raw quote the string i.e. r' pasted path from explorer '). Long before python was widespread (ArcINFO commandline) I used the 2nd method to turn a folder of files into a batch file, it's tedious but it works, which is why I wrote the python script. – Michael Stimson May 3 '18 at 22:26

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.