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

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@barrax
S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B03.jp2@barrax
S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B04.jp2@barrax
S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B08.jp2@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?

Thanks in advance

Regards

Sajid

Sajid,

maybe not useful (?): t.rast.export does that for registered maps.
Maybe fake a strds or check the code there-in?

Nikos

* Sajid Pareeth <spareeth@gmail.com> [2016-11-10 10:02:07 +0100]:

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@barrax>
<S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B03.jp2@barrax>
<S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B04.jp2@barrax>
<S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B08.jp2@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?

Thanks in advance

Regards

Sajid

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Nikos Alexandris | Remote Sensing & Geomatics
GPG Key Fingerprint 6F9D4506F3CA28380974D31A9053534B693C4FB3

On Thu, Nov 10, 2016 at 10:02 AM, Sajid Pareeth <spareeth@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@barrax
S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B03.jp2@barrax
S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B04.jp2@barrax
S2A_OPER_MSI_L1C_TL_MTI__20160810T122618_A005911_T30SWJ_B08.jp2@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