[GRASS-user] Attempt to export (r.out.gdal) produces sometimes an error and sometimes not

Markus Metz markus_metz at gmx.de
Wed Sep 24 08:41:50 EDT 2008



Nikos Alexandris wrote:
>> r.info composite_b123 -tr
>>     
> min=0
> max=32767
> datatype=CELL
> [Raster MASK present]
>
> 1st attempt to export:
>  > r.out.gdal in=composite_b123
> out=/home/nik/grassdb/peloponnese/data/exports/composite_b123.tif
> Exporting to GDAL data type: UInt16
> Segmentation fault
> [Raster MASK present]
>
> 2nd attempt to export without any change:
>   
>> r.out.gdal in=composite_b123
>>     
> out=/home/nik/grassdb/peloponnese/data/exports/composite_b123.tif
> Exporting to GDAL data type: UInt16
> Warning 1: Lost metadata writing to GeoTIFF ... too large to fit in tag.
>  100%
> WARNING: Input raster map constains cells with NULL-value (no-data). The
>          value -32768 was used to represent no-data values in the input
>          map.You can specify nodata value by nodata parameter.
> Warning 1: Lost metadata writing to GeoTIFF ... too large to fit in tag.
> r.out.gdal complete.
> [Raster MASK present]
>
>   
Apart from the segmentation fault answered by Glynn, I see more problems
here.

The nodata value of -32,768 is not valid, effectively discarding nodata
information, because the range of UInt16 is 0 to 65,535 and -32,768 is
out of range, i.e. there are no cells with -32,768 in the output
GeoTIFF. The range of composite_b123 is 0 to 32,767, therefore a
reasonable nodata value would be anything between 32,768 and 65,535. You
can try to use r.out.gdal with the options e.g. type=UInt16 nodata=32768
or type=Int16 nodata=-32768. Generally it seems to be a good idea to
specify the options type and nodata (if needed) for r.out.gdal

The next problem I suspect is the export of a raster probably generated
with r.composite (as the name suggests). This will only be displayed
with the same colours as in GRASS if the colortable provided with the
GeoTIFF metadata is properly interpreted. As I have shown previously [1]
this is not always the case, especially for UInt16, even GRASS struggles
with the re-import of UInt16 type GeoTIFFs [2]. A safer alternative
would be to put the three rasters used for r.composite in a group and
export the group with type=Byte if possible. The resulting GeoTIFF
should be a RGB image that can be displayed with any image viewer, an
easy way to check that the three bands are assigned red, green, and blue
as intended, otherwise swap the order in the ref file.

I hope that helps

Markus

[1] http://trac.osgeo.org/grass/ticket/73#comment:13
[2] http://trac.osgeo.org/grass/ticket/73#comment:15


More information about the grass-user mailing list