Skip to main content
Question

Extract mask from raster

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

jdh
Contributor
Forum|alt.badge.img+40
  • 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.