Question

Extract mask from raster

  • 28 November 2019
  • 1 reply
  • 24 views

Good afternoon. I have one raster with 4 bands (RGBA). The alpha band shows transparency (255 is transparent and 0 is opaque). Furthermore I have another raster that I have to multiply with first. Is it possible to extract any values (i.e R=179,G=227,B=249,A=255) and set alpha band as 0 (opaque) and leave the rest of raster with its original values for multiplying later?

Thank you at all.


1 reply

Badge +22

Normally the alpha band works in the reverse. Values of 0 are transparent and 255 are opaque.

 

 

That said, you can use the rasterExpressionEvaluator with conditional expressions. https://knowledge.safe.com/articles/1226/using-conditions-with-the-rasterexpressionevaluato.html

 

 

Example

 

Alpha8: if (A[0]==179 && A[1]==227 && A[2] == 249 && A[3]==255, 0, A[3])

If the pixel is (179,227,249,255) set it to 0, otherwise keep the existing value.

 

you would set the RGB bands to simply A[i] with i being the index of the band.

Reply