r.out.gdal and multiband output - was Re: [GRASS-user] problem whit raster images

Markus Neteler neteler at itc.it
Sun Jul 9 03:46:21 EDT 2006


On Thu, Jul 06, 2006 at 09:33:18AM +0200, Markus Neteler wrote:
> On Thu, Jul 06, 2006 at 06:58:01PM +1200, Hamish wrote:
...
> > any ideas on how to output 3 R,G,B rasters into a single 3-band GeoTIFF
> > without resolution loss? (ie no r.composite 256->32 col/band reduction)
> 
> Hi Hamish,
> since r.out.gdal is still a shell wrappper to gdal_translate,
> everything possible with gdal_translate should be(come) possible
> with r.out.gdal.
>  
> > r.out.gdal only takes a single input= map.
> 
> You could try to change that to multi.
> BUT: I guess that gdal_translate only accepts one map.
> 
> > run r.out.gdal for each band then merge somehow with gdal_translate??
>

[... my useless comments ...]

Now I remember it:
The best way will be to create a VRT [1] file with all channels
defined in it, then run the gdal_translate.

Means:
- if single band, let r.out.gdal work as is
- if multi band, implement creation of a temporary VRT file, then
  use this VRT file as input to gdal_translate in the script
  and throw it away at the end.

Hint:
To quickly get the VRT syntax right, use r.out.gdal on a single
file with format VRT on a GRASS raster map. Even easier:
Take create_VRT_file() from i.in.spotvgt :-)


Markus

[1] https://gdal.osgeo.org/gdal_vrttut.html




More information about the grass-user mailing list