Skip to main content
Solved

Swapping Raster Bands


Forum|alt.badge.img

Can anyone provide advice regarding the easiest method to swap raster bands around?

For example, I have a 4 band raster,

Band{0} Interpretation Type (Red16)

Band{1} Interpretation Type (Green16)

Band{2} Interpretation Type (Blue16)

Band{3} Interpretation Type (Uint16)

And I want to complete the following swapping

Band{3} -> becomes -> Band{0}

Band{0} -> becomes -> Band{1}

Band{1} -> becomes -> Band{2}

Band{2} -> becomes -> Band{3}

Is it possible to manipulate/flip the bands directly within the raster? (How would this be done?)

Or do the bands need to be separated into singular elements and then recombined and ordered? (How would this be done?)

Also relating to this example, in the source raster described above, the Interpretation type of band{3} differs from Bands{0}..{2}. If the bands were swapped would I need to also need to change the interpretation types as below?

Band{3} Interpretation Type (Uint16) -> becomes -> Band{0} Interpretation Type (Red16)

Band{0} Interpretation Type (Red16) -> becomes -> Band{1} Interpretation Type (Green16)

Band{1} Interpretation Type (Green16) -> becomes -> Band{2} Interpretation Type (Blue16)

Band{2} Interpretation Type (Blue16) -> becomes -> Band{3} Interpretation Type (Uint16)

Essentially, if I wish to view a raster as an RGB do I need to swap/change/update the interpretation type to the RGB channel which I want it to be visualise as? I.e. is just swapping the band position NOT sufficient to actually effect a colour change? Do I need to swap band position AND interpretation?

Any explanation as to the issues above would be gratefully received.

Finally, out of interest, why would the interpretation type of Band{2} differ from the other 3 bands?

I am using FME Desktop 2015.1.

Regards,

Rob

Best answer by taojunabc

Just now I found that FME provides a transformer named RasterBandOrderer. Use it can be very simple to achieve the purpose.

.

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

8 replies

takashi
Evangelist
  • February 6, 2017

Hi @rob14, of course you can separate the bands and recombine them after reordering (e.g. RasterBandSeparator ->Counter -> AttributeValueMapper -> Sorter -> RasterBandCombiner), but I think the RasterExpressionEvaluator with this setting does the trick simply.


Forum|alt.badge.img
  • Author
  • February 6, 2017

Hi @takashi,

As always thanks for the advice.

I will try this method as it seems a more straight forward method of completing the swapping process (as opposed to splitting/sorting/combining).

I assume from the included transformer image, that what you are effectively doing is treating the interpretation types as your empty 'attribute containers' and you are updating the value with the band value? An elegant solution.

Thanks again I will try this.

Rob


taojunabc
Participant
Forum|alt.badge.img+6
  • Participant
  • February 6, 2017

You can use the following methods.

  1. RasterBandSeparator to split bands
  2. AttributeValueMapper to set new band order
  3. Sort by new band order
  4. Recombin bands

Red16,Green16,Blue16 and UInt16? They are also 16 bit unsigned integers, so you don't need to change the interpretation.


taojunabc
Participant
Forum|alt.badge.img+6
  • Participant
  • February 6, 2017
taojunabc wrote:

You can use the following methods.

  1. RasterBandSeparator to split bands
  2. AttributeValueMapper to set new band order
  3. Sort by new band order
  4. Recombin bands

Red16,Green16,Blue16 and UInt16? They are also 16 bit unsigned integers, so you don't need to change the interpretation.

Oh, as Takashi says, it's easier to use RaserExpressionEvaluator, and it's a better choice.

 

 


Forum|alt.badge.img
  • Author
  • February 6, 2017

Hi @taojunabc

Thank you for the workflow you sent, it is always good to know a variety of methods. I had tried something similar but had missed a couple of vital steps.

Thanks also for the confirmation that all data types were the in fact the same at 'source'. I realise now that you are effectively not changing the data type as such, but that you are just telling the system to treat a given data type as a R, G, or B colour and then display it within this band. As there are only 3 options in this instance, the 'unused' band remains unassigned to a colour.

I guess that if you wanted to, you could only use any; or only, 1, 2 or bands (from the 4 band source)

Red16,Uint16,Uint16,Uint16

 

Red16,Uint16,Blue16,Uint16

 

Uint16,Uint16,Blue16,Uint16

 

etc.

 

Thanks for the post as this has helped my understanding.

Rob


taojunabc
Participant
Forum|alt.badge.img+6
  • Participant
  • Best Answer
  • February 8, 2017

Just now I found that FME provides a transformer named RasterBandOrderer. Use it can be very simple to achieve the purpose.

.


takashi
Evangelist
  • February 8, 2017
taojunabc wrote:

Just now I found that FME provides a transformer named RasterBandOrderer. Use it can be very simple to achieve the purpose.

.

oops, I've missed this transformer. This exactly fits to the purpose :-)

 


Forum|alt.badge.img
  • Author
  • February 8, 2017
taojunabc wrote:

Just now I found that FME provides a transformer named RasterBandOrderer. Use it can be very simple to achieve the purpose.

.

Hi @taojunabc

 

 

Thanks very much for sending this update, that is really useful.

 

 

Regards,

 

 

Rob

 

 


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