Skip to main content
Hi, I'm adding some single band rasters together within FME and I would like to normalise the cell values.

 

 

I'm using the RasterBandMinMaxExtractor to pull the min and max values before going into a RasterExpressionEvaluator. I have right clicked on the RasterBandMinMaxExtractor and exposed elements for _band{0}.min and _band{0}.max but when I use this expression it fails to create an output:

 

 

(((A 0]-@Value(A:_band{0}.min)))/(@Value(A:_band{0}.max)-@Value(A:_band{0}.min)))

 

 

Is there something wrong with my expression?

 

 

Thank you!
Hi,

 

 

Looks like there is no problem, but the division result will be an integer if both operands were integer values. Therefore, the resultant raster would be a binary image (0 or 1), if every cell value was integer. If your situation was so, consider performing cast an operand of the division operator to floating point value. See also this thread.

 

How to use the ExpressionEvaluator? (http://fmepedia.safe.com/CommunityAnswers?id=906a0000000d6XBAAY)

 

 

Takashi
Hello, thanks for the reply. I tried your suggestion but it still didn't create an output. However I did the calculations in stand alone ExpressionEvaluators also adding +0.0 value then passed those attributes to my RasterExpression and it created the right result! So my new expression looked like this:

 

 

((A>0]-@Value(A:NEWMIN))/@Value(A:DIVIDE))*100

 

 

Thanks for the suggestion
Good to hear you accomplish the purpose :-)

 

 

Probably this expression can be used to get the same result.

 

100.0*(A>0]-@Value(A:_band{0}.min))/(@Value(A:_band{0}.max)-@Value(A:_band{0}.min))

 

 

The point is that I added "100.0*" to the head of the expression.

 

Since * and / operators have same precedence, the calculation will be performed from left to right. i.e. firstly 100.0 (floating point number) is multiplied by "(Aq0]-@Value(A:_band{0}.min))", the result will be a floating point number.

 

And then, the division will be performed with the result, so the final result will also be a floating point number.

Reply