Skip to main content
Solved

RasterExpressionEvaluator / RGB Band Expression Query


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.

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

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+38

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 :)


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