[GRASS-user] Retaining the raster name, while exporting a group to other formats

Markus Metz markus.metz.giswork at gmail.com
Mon Nov 14 05:29:10 PST 2016


On Thu, Nov 10, 2016 at 10:02 AM, Sajid Pareeth <spareeth at gmail.com> wrote:
>
> Hi all
>
> I am exporting a group of rasters to single stacked GTiff and ENVI format
files.
>
> Here is my group:
> i.group S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_10m -l
> group <S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_10m>
references the following raster maps
> -------------
> <S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B02.jp2 at barrax>

> <S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B03.jp2 at barrax>

> <S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B04.jp2 at barrax>

> <S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B08.jp2 at barrax>

> -------------
>
> I use the following export command:
> r.out.gdal input=${BASE}_10m
output="${MYDATA}/${FOLDER}Barrax/20m/${BASE}_10m" format=ENVI
>
>
> But the band names in the output ENVI or GTiff files are changed to "Band
1", "Band 2", "Band 3", "Band 4".
>
> Is there any way to retain the original raster names for the individual
bands in the final stacked image?
>

In GDAL, raster bands do not have names, they are numbered. The name of
each input band could be used as description with GDALSetDescription() or
the input name could also be stored as a band-specific metadata item. In
any case, it depends on the output format if the input name can be used as
description or for a band-specific metadata item. With
GDALSetDescription(), gdalinfo would then report e.g.

Band 1 Block=1678x1 Type=Float64, ColorInterp=Gray
  Description = elev_state_500m

Other applications including r.in.gdal might not check for any
band-specific description upon import.

Markus M
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20161114/1a44e5b0/attachment.html>


More information about the grass-user mailing list