Skip to main content
Question

Extract mask from raster

  • November 28, 2019
  • 1 reply
  • 79 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

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • November 28, 2019

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.

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