Machine learning - saving .Tiff as RGB in R for annotation

Hi Folks,

My student is trying to save some netCDF data as .Tiff using writeRaster in R in order to annotate it in SuperAnnotate (to ultimately identify Atmospheric Rivers). When she opens the tiff file in SuperAnnotate it appears as greyscale rather than RGB (but it looks fine when she plots it in R). I was wondering if anyone has any solutions for this as our googling has not found a solution.

Thanks :slight_smile:

Hi Kim

I would have a look at the file using gdalinfo, there should be a section like this:

Band 1 Block=1264x6 Type=Byte, ColorInterp=Palette
  NoData Value=0
  Metadata:
    actual_range={0,120}
    long_name=z
    NETCDF_VARNAME=z
    _FillValue=nan
  Color Table (RGB with 256 entries)
    0: 0,0,139,0
    1: 0,0,139,255
    2: 0,0,139,255
    3: 0,0,139,255
    4: 0,0,139,255
    5: 0,0,139,255
    6: 0,0,139,255
    7: 0,0,139,255
...

Its not uncommon for tiff to be saved without the Color Table, which might mean it would be displayed in greyscale.

If that is the problem, I would try:

writeRaster([all that other stuff], options="PHOTOMETRIC=RGB")

but I am guessing pretty wildly here.

Thanks for your help!
We managed to get that to work. Although SuperAnnotate still wasn’t happy with the file, so we’re going to use ArcGIS instead