Skip to main content
Solved

Keeping raster attributes when writing out rasters

  • September 12, 2017
  • 9 replies
  • 48 views

Forum|alt.badge.img+1

Hi,

I have an FME2017 desktop workbench where I am writing out to rasters. I don't mind which raster format I write out to (eg. GeoTiff, Esri Ascii Grid,) as long as the raster is readable in ESRI ArcGIS software. I am currently writing out to GeoTiff successfully and the three bands (R, G, B) are displaying correctly in ArcGIS.

The raster only has 10 distinct combination of bands and I would like to create a new band that is based on the combination of the RGB bands and give each cell in the raster a value for this new band.

I would then like to output this new band with the Raster and make the raster displayable by this band in ArcGIS.

Does anyone know how to do this?

Thank you in advance

Best answer by jdh

In that case you want to use a RasterPaletteGenerator which will convert selected bands to a new band with a palette.

View original
Did this help you find an answer to your question?

9 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • September 12, 2017

You can use a RasterExpressionEvaluator to create additional band(s) based on the values of other bands.

Additional bands can be displayed in arcmap by changing the setting of the layer symbology to stretched and selecting the appropriate band.

My personal preference is for GeoTiffs when working with ArcMap, though be advise that there is a 2GB limit.


Forum|alt.badge.img+1
  • Author
  • September 12, 2017

Thank you for your response @jdh. But I don't I think I explained myself properly.

The 10 distinct combinations of the 4 RGBA bands are colours and the new band that I want is just a number that represents each of these colours. Therefore I don't think I can use the RasterExpressionEvaluator for this, as far as I am aware. I thought perhaps the answer lies in palettes. So I tried to define a palette using the AttributeCreator by adding the following text into the text editor:

RGBA32 0 0,0,0,0 1 0,0,254,255 2 50,101,254,255 3 127,127,0,255 4 254,203,0,255 5 254,152,0,255 6 254,0,0,255 7 254,0,254,255 8 229,254,254,255

I followed this with the RasterPaletteAdder:

However I keep getting this error:

@RasterPaletteAttributes: A selected band has intepretation 'RED8', which is not a valid interpretation for a band with palettes. Please ensure that only bands with an interpretation of UINT8, UINT16, or UINT32 are selected. @SelectRaster may be used to modify selection

I feel like I'm on the right track but am missing something...


courtney_m
Contributor
Forum|alt.badge.img+12
  • Contributor
  • September 12, 2017

Hi, @aquamarine. Have you tried using the RasterInterpretationCoercer before your RasterPaletteAdder? You can force the interpretation to UINT8.


Forum|alt.badge.img+1
  • Author
  • September 12, 2017
courtney_m wrote:

Hi, @aquamarine. Have you tried using the RasterInterpretationCoercer before your RasterPaletteAdder? You can force the interpretation to UINT8.

Thanks @courtney_m

 

Adding the RasterInterpretationCoercer and forcing it to UINT8 solved the problem! Are you able to explain why I needed to do this? I am not very familiar with raster interpretations and bands and palettes so am a bit perplexed with all this.

 

Regards

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • September 12, 2017

In that case you want to use a RasterPaletteGenerator which will convert selected bands to a new band with a palette.


courtney_m
Contributor
Forum|alt.badge.img+12
  • Contributor
  • September 12, 2017
aquamarine wrote:
Thanks @courtney_m

 

Adding the RasterInterpretationCoercer and forcing it to UINT8 solved the problem! Are you able to explain why I needed to do this? I am not very familiar with raster interpretations and bands and palettes so am a bit perplexed with all this.

 

Regards

 

Only rasters with an interpretation of UInt8, UInt16, or UInt32 can contain a palette. So in order to add a palette to your raster, you have to first do a transformation on the raster to force it to have an appropriate interpretation.

 

 


Forum|alt.badge.img+1
  • Author
  • September 12, 2017
jdh wrote:

In that case you want to use a RasterPaletteGenerator which will convert selected bands to a new band with a palette.

Thansk @jdh

 

this method also works for me. It is probably better for me to use the RasterPaletteGenerator than the RasterPaletteAdder in this case, because I am exporting to GeoTiffs and GeoTiffs can only have 1 band.

takashi
Evangelist
  • September 13, 2017

Hi @aquamarine, as @jdh suggested, you can use the RasterPaletteGenerator to transform an RGB24 or RGBA32 raster into a UInt8, UInt16, or UInt32 single band raster with a palette. However, you cannot specify which destination cell value should be mapped to a specific (R,G,B) or (R,G,B,A) combination. In other words, the order of the palette entries cannot be controlled.

If you need to specify the destination single cell value corresponding to a specific (R,G,B) or (R,G,B,A) combination, the RasterExpressionEvaluator would still be a solution.
For example, assuming the mapping rule between each destination cell value and original (R,G,B) combination has been given as:

0  0,0,0
1  0,0,254
2  50,101,254
3  127,127,0
4  254,203,0
5  254,152,0
6  254,0,0
7  254,0,254
8  229,254,254

These two RasterExpressionEvaluators transform an RGB24 raster into a UInt8 single band raster. See also the attached demo: rgb-raster-to-single-band-raster-demo.fmw (FME 2017.0)

0684Q00000ArKWVQA3.png


Forum|alt.badge.img+1
  • Author
  • September 13, 2017
takashi wrote:

Hi @aquamarine, as @jdh suggested, you can use the RasterPaletteGenerator to transform an RGB24 or RGBA32 raster into a UInt8, UInt16, or UInt32 single band raster with a palette. However, you cannot specify which destination cell value should be mapped to a specific (R,G,B) or (R,G,B,A) combination. In other words, the order of the palette entries cannot be controlled.

If you need to specify the destination single cell value corresponding to a specific (R,G,B) or (R,G,B,A) combination, the RasterExpressionEvaluator would still be a solution.
For example, assuming the mapping rule between each destination cell value and original (R,G,B) combination has been given as:

0  0,0,0
1  0,0,254
2  50,101,254
3  127,127,0
4  254,203,0
5  254,152,0
6  254,0,0
7  254,0,254
8  229,254,254

These two RasterExpressionEvaluators transform an RGB24 raster into a UInt8 single band raster. See also the attached demo: rgb-raster-to-single-band-raster-demo.fmw (FME 2017.0)

0684Q00000ArKWVQA3.png

Thank you @takashi .  I don't need to change the order of the palette entries in this case, but in future this information on how to use the RasterExpressionEvaluator could come in very handy.  Thanks!!

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings