Skip to main content
Hi,

 

 

I have a raster file which identifies vegetation. There is a distact background colour, and then levels of green identify vegetation. 

 

I'm looking to identify certain rgb values of the vegetation and transform into polygon.

 

 

I've tried RasterExpressionEvaluator and then RasterPaletteExtractor but I keep having errors.

 

Is there something simple like a tester where I could test;

 

if ( Ap0]!=210 && Ap1]!=180 && Ap2]!=140 && Ap3]!=255 )

 

     output ;

 

 

 

 
Hi,

 

 

The "if" function in the expression for the RasterExpressionEvaluator requires three arguments.

 

1st: test condition for a cell value

 

2nd: the replacement value if the condition was true

 

3rd: the replacement value if the condition was false

 

 

Takashi
Hi,

 

In a script to "trace" lines in a grayscale raster, i use RasterExpressionEvaluator like you do, but like Takashi says it needs 3 arguments.

 

 

I replace the unwanted values by a no-data value, wich you set first.

 

 

if(A>0]== 4 || A 0]== 16 || A 0]== 32 || A 0]== 36 || A 0]== 46 || A 0]== 48 || A 0]== 14 || A 0]== 54 || A 0]== 50 || A 0]== 2,0,A20])

 

All unwanted values are set to value =0, Rest keep their value, in my case Ac0].

 

Then i used a RasterCellCoercer with ExtractNoDataValues=No  to only keep the cells i want (that is rest have no data in subsequents stages of the proces).

 

(you can also use RasterCellValueReplacer to simpify or clean unwanted colours).

 

 

You cannot just "select" cells, as it is always a raster wich is  rectangular. You always select all cells by default, so you must set the ones you do not want to participate in some proces to, most commonly done to some no data value.

 

 

 

Reply