3

I would like to convert more than 300 orthophotos produced at scale 1:8.000 with a pixel size of 0.8m X 0.8m from Ecw format to Tiff format and after resampling pixel values.

My aim is to batch convert the input format (Ecw) to output format (Tiff) and after to resample the pixel size (values) 10mX10m.

How could I right this script using gdal to batch process this raster files.

I'm using FWTools on Windows XP

Thanks

urcm
  • 22,533
  • 4
  • 57
  • 109
Gabriel Giroux
  • 261
  • 1
  • 3
  • 7

3 Answers3

4

You might want to consider using gdalwarp instead of gdal_translate as it gives you the ability to control the output pixel size more precisely.

eg.

gdalwarp -tr 10 10 src.ecw dst.tif

You can also specify a variety of resampling kernels. For such radical downsizing averaging might be appropriate.

eg.

for %i in (*.ecw) do gdalwarp -ps 10 10 -r average %i %~new_resize.tif
AndreJ
  • 76,698
  • 5
  • 86
  • 162
Frank Warmerdam
  • 1,594
  • 9
  • 9
  • Thanks you Aragon and Frank for your answers to my question. This would be helpfull for me. I'll give you sowme feet-back about the processing to see if all work fine. Regards

    Regards

    – Gabriel Giroux May 20 '12 at 00:37
2

you can do with this way:

for %i in (*.ecw) do gdal_translate -of GTIFF -scale -size 10% 10% %i %~new_resize.tif

i hope it helps you....

urcm
  • 22,533
  • 4
  • 57
  • 109
1

Sorry for not being able to give you my feed-backs regarding my request on how writing a batch script to convert and resample multiple orthophotos from one directory to another.

The reason is because I was working on another project that was very urgent. So yesterday I took the time to look at the code that Frank provided to suit my case, adding some parameters. The only thing I noticed is that under Windows you need to write a double wildcard to run the script.

Here is my final script.

Thank you for your help much appreciated.

@echo=off
set OLDDIR=%CD%
cd /d "E:\Imagerie\Ortho_2009\ortho2009_10cm\RGB\"
for %%f in ("*.ecw") do gdalwarp -s_srs EPSG:26918 -t_srs EPSG:32188 -r cubic -tr 10 10 -of GTiff -co "TFW=YES" "%%~nxf" "E:\Imagerie\Ortho_2009\Ortho_test\result_gtiff/%%~nf.tiff"
cd /d %OLDDIR%
pause  

Thank you guys...

Gabriel Giroux
  • 261
  • 1
  • 3
  • 7