A quick GDAL utilities use case

Today I had to perform some raster data management for my colleagues and ended up with a little bit o CLI kung-fu with GDAL utilities. By the way I want to share them also as a reminder for the next time :-) I had a number of Arc/Info ASCII Grid files to convert, merge and finally transform to serve them on a WMS service.

First, convert all of them from agr to tiff (execute it all in one line)

find . -name "*.agr" -exec bash -c 
'file={};i=${file%.*};
 gdal_translate -of GTiff -co "TILED=YES" $file $i.tiff ' \;

Then merge all of them (see the acutes to execute ls and expand the list of files):

gdal_merge.py -o 31.tiff `ls *.tiff`;

And finally an easy transform from UTM31N (ETRS89) to Lat/Lon (ETRS89)

gdalwarp -s_srs EPSG:25831 -t_srs EPSG:4258 31.tiff 4258.tiff

I know this is pretty basic stuff, but not everybody knows how to combine good CLI programs like find to avoid some extra executions.

Responder

  • Las direcciones de las páginas web y las de correo se convierten en enlaces automáticamente.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <img>
  • Saltos automáticos de líneas y de párrafos.
  • Each email address will be obfuscated in a human readble fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

Más información sobre opciones de formato