[GRASS-user] Exporting RGB Composite Images to GeoTIFF

Michele Toma michele.toma at airborne.aero
Fri Jul 29 09:05:54 PDT 2016


Hi Moritz/everyone,

I really appreciate all of the information. 

The original issue was exporting an RGB composite image from GRASS to a GeoTIFF format that could be opened in Global Mapper. I had created a pansharpened RGB image and attempted to export the image, but the settings I used created entirely black images. 

When I exported using r.out.gdal with no create options, the resulting image would not open in Global Mapper. I then tried to export without the color table which gave me a grayscale image. So, my understanding was that the data type was wrong. The errors I got when trying to export as Byte said to try using Float64. But after trying to use that data type and all other data types in the drop down list, I ended up with a black image. In addition to changing the data type, I opted to skip exporting the color table according to the directions on the r.out.gdal documentation page. What options should I be selecting to export the image? Is there a simpler method to exporting the image that I am not aware of?

When trying to export in QGIS, I use GRASS tools to open the rbg composite raster and then right click on the layer -> Save As... The options that I use are "export as a rendered image" and in create options: "No compression". This seems to work for me. However, I have run into another issue where I cannot get rid of the black borders/null data that surround the image. The borders are removed in GRASS after running r.null on the rgb composite image. They reappear when opening in QGIS using GRASS tools. (Note: I am using QGIS 2.8.2).

Again, thank you for all your help.

-Michele

-----Original Message-----
From: Moritz Lennert [mailto:mlennert at club.worldonline.be] 
Sent: Sunday, July 24, 2016 2:23 AM
To: Michele Toma; Markus Neteler
Cc: grass-user at lists.osgeo.org
Subject: Re: [GRASS-user] Exporting RGB Composite Images to GeoTIFF

On 22/07/16 18:07, Michele Toma wrote:
>
> I was able to resolve my issue (export the composite image so that it 
> can be opened in Global Mapper and Photoshop) by opening it in QGIS 
> using the GRASS Tools plugin. Click “Add raster layer” button and 
> navigate to the composite image and click OK. Once it was added to 
> QGIS, I right-clicked the raster layer in the Layer menu and selected 
> the Save As… option. Then in the Save As… window, I selected “rendered 
> image” as the output and left all other options as the default. This 
> newly exported image allowed me to open the it in other programs.
>

Happy that you found a solution for yourself, but this should "just work" in GRASS as well.

To get back to your original issues:

On 21/07/16 02:53, Michele Toma wrote:
> I am having trouble exporting a composite RGB image into a GeoTIFF 
> format that I can open in Global Mapper, Photoshop, or other programs. 
> This is using Landsat 8 imagery. I am able to open the composite image 
> in QGIS, but not in Global Mapper or Photoshop.

Can you really not open it, or it just appears black/grey or something like this ? GeoTIFF metadata cannot be handled by many normal graphic programs.

If your interested, here's the lengthy discussion on these issues: 
http://trac.osgeo.org/grass/ticket/73

As a result the manual page now states:

"r.out.gdal exports may appear all black or gray on initial display in other GIS software. This is not a bug of r.out.gdal, but often caused by the default color table assigned by that software. The default color table may be grayscale covering the whole range of possible values which is very large for e.g. Int32 or Float32. E.g. stretching the color table to actual min/max would help (sometimes under symbology)."

and

"GeoTIFF caveats

GeoTIFF exports can only be displayed by standard image viewers if the GDAL data type was set to Byte and the GeoTIFF contains either one or three bands. All other data types and numbers of bands can be properly read with GIS software only. Although GeoTIFF files usually have a .tif extension, these files are not necessarily images but first of all spatial raster datasets, e.g. SRTM DEM version 4."

and a bit further in the "Improving GeoTIFF compatibility" section:

"Skip exporting the color table. Color tables are not always properly rendered, particularly for type UInt16, and the GeoTIFF file can appear completely black. If you are lucky the problematic software package has a method to reset the color table and assign a new color table (sometimes called symbology). "

Another issue is color table handling, which also differs from program.

When you open it in QGIS, does it open with the same colors as in GRASS ?

[...]

>
> a.       i.colors.enhance red=brovey.red at Osaka
> green=brovey.green at Osaka blue=brovey.blue at Osaka
>
> 6.       Create composite RGB. I’ve run the two commands below and
> both do not produce what I need:

Could you explain exactly what it is you expected and that you didn't get ?

>
> a.       r.out.gdal input=brovey.rgb at Osaka output=brovey.rgb.tif
> format=GTiff

Where does brovey.rgb come from ? r.composite ?


>
>
> Another method that I have tried using an example on the r.out.gdal 
> documentation page:
>
>
>
> i.group group=brovey_group input=brovey.red,brovey.green,brovey.blue
>
> g.region rast=brovey.blue -p
>
> r.out.gdal in=brovey_group output=brovey_group.tif type=Float64 \
>
> createopt="PROFILE=GeoTIFF,INTERLEAVE=PIXEL,TFW=YES"
>
>

type=Float64 cannot be handled by many software packages...

>
> The result is an image with distorted colors when opened in QGIS.
> Water has turned a reddish brown color.

You can try to export the color table with r.colors.out and massage the output to use it as input for QGIS.

At this stage, I don't really understand, yet, what your issue actually
was:

- color table export from GRASS to other software ?
- defining the tiff's parameter so it can be read by other software ?
- something else ?


Moritz


More information about the grass-user mailing list