I have 118 asc grid files, I need to convert them to TIFF. I've tried gdal translate but unfortunately GIS keeps crashing. I was hoping I could use python to loop through all of them and save them.
Asked
Active
Viewed 776 times
1
1 Answers
1
As suggested, creating a windows batch file should be your best solution. You can try this script, just make sure the paths and your source crs are correct.
@ECHO ON
SETLOCAL EnableDelayedExpansion
SET mypath_in=G:\Input\Folder
SET mypath_out=G:\Output\Folder\
FOR /F %%i IN ('DIR /B %mypath_in%*.asc') DO (
SET infile=%%i
SET outfile=!infile:.asc=.tif!
"C:\Program Files\QGIS 3.20"\bin\gdal_translate.exe -co WORLDFILE=YES -a_srs EPSG:3044 -of GTIF "%mypath_in%!infile!" "%mypath_out%!outfile!"
)
sn1ks
- 2,982
- 12
- 28
-
Hello, I have tried your script however, although it is reading the asc it is unable to convert them. I get the error "filename, directory name or volume label syntax is incorrect. I have made sure that all the paths are correct and the crs too. – Amrie Singh Oct 19 '21 at 12:56
-
-
Is there a way to amend this to use grass r.stats on all those files too to get the statistics for each category? I need them to be saved to a csv which I will use to analyse further. – Amrie Singh Oct 19 '21 at 20:53
-
gdal_translateon the command line is probably the easiest solution. See https://gis.stackexchange.com/a/88087/79 – Ian Turton Oct 19 '21 at 12:14