Skip to main content
Solved

RasterExpressionEvaluator / RGB Band Expression Query

  • May 23, 2024
  • 3 replies
  • 112 views

galigis
Enthusiast
Forum|alt.badge.img+20

Hi All,

I’m having some issues to filter raster pixels by the band expression using the RasterExpressionEvaluator tranformer,

What the expression to select the pixels with the following band combination B(0)=64; B(1)=128;B(2)=104?

 

I have used the following settings but hasn’t worked:

 

Any ideas please? :)

Best answer by virtualcitymatt

It depends a little on what you mean by “select the pixels”.

If you want to extract or keep just those pixels then you can try something like this
 

 @if(A[0]!=64&&A[1]!=128&&A[2]!=104,0,A[0])


You will need to use the expression once for each band like this:
 

This will set all pixels to 0,0,0 except pixels with an RGB value of 64,128,104.

If, however, you want the pixels instead as a polygon you can use the RasterToPolygon coercer - this will give you the vector representation and the band vales which you can later use to test on.

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.

3 replies

galigis
Enthusiast
Forum|alt.badge.img+20
  • Author
  • Enthusiast
  • May 24, 2024

Any ideas on this please? I have been playing around but can’t get it to work...thanks! :)


virtualcitymatt
Celebrity
Forum|alt.badge.img+47

It depends a little on what you mean by “select the pixels”.

If you want to extract or keep just those pixels then you can try something like this
 

 @if(A[0]!=64&&A[1]!=128&&A[2]!=104,0,A[0])


You will need to use the expression once for each band like this:
 

This will set all pixels to 0,0,0 except pixels with an RGB value of 64,128,104.

If, however, you want the pixels instead as a polygon you can use the RasterToPolygon coercer - this will give you the vector representation and the band vales which you can later use to test on.


galigis
Enthusiast
Forum|alt.badge.img+20
  • Author
  • Enthusiast
  • May 29, 2024

Thanks @virtualcitymatt  - it has worked perfectly :)