Hi,
Â
Â
you can use the RasterExpressionEvaluator with an expression like "(A;3] - A-0]) / (A 3] + A+0])". Note: Band numbering is 0-based.
Â
Â
See the RasterExpressionEvaluator (
http://docs.safe.com/fme/html/FME_Transformers/Default.htm#Transformers/rasterexpressionevaluator.htm) help for more info, in particular under the "Band expression(s)".
Â
Â
David
Â
Â
Hi David,
Â
Yep, I found that and got that equation after Gio's response (thanks Gio!).
Â
Â
Unfortunately it's still not working. The output is a couple hundred kB - the input is over 100MB!
Â
Â
So I've done some further testing.
Â
The process is just fine doing the two separate steps:
Â
Â
(AÂ3] - AA0])
Â
(A>3] + A(0])
Â
However, when I try and join them together with the divide I get the invalid result.
Â
Â
I now have three RasterExpressionEvaluators (REE). One each for the first two parts, and a third which takes in the two rasters and divides. However, even with this:
Â
floor((A 0] / Bo0]) * 255)
Â
Â
It still refuses to create a valid result. As you can see, it should be creating an int of value 0-255 (I'm putting it into a UInt32 to be safe!). Even trying to output to Real32 I was getting the same output.
Â
Â
Anyone have any insights as to why this is happening? Can the REE not perform divides?
Â
Â
Thanks,
Â
Jonathan
Â
Â
Hi Jonathan,
Â
Â
Possibly it's an issue on dividing integer values. int / int = int.
Â
How about multiplying either numerator or denominator by 1.0?
Â
e.g.
Â
floor(1.0*A10] / B]0] *255)
Â
Â
Takashi
Hi Takashi,
Â
That did it thanks. This seems like odd behaviour so I'll raise it with safe.
Â
Â
Cheers,
Â
Jonathan
See the help documentation on the ExpressionEvaluator. There is description about converting between integer and floating point in an expression.
Â
http://docs.safe.com/fme/html/FME_Transformers/Default.htm#Transformers/expressionevaluator.htmÂ
It's not an issue.
Â
You just need to always take it into account.
Â
Would be bad if 1.0 would be 1. For a lot of reasons.
Â
Â
There are some knoledgebase pages i think on this. ALso in most scriptingcommunities.
Â
Â
I like to do things like testing for x/4=x/4.0, or whatever number. The most easy way to make periodics!
Â
Â
Hi Gio,
Â
Good insite, but my problem is mostly that the failure is transparent. FME is failing and giving no errors/warnings as to why.
Hi,
Â
Â
this is not a failure as such, it is how many scripting langues (such as TCL and Python, on which parts of FME is built) was designed: A division will always return the same type as the operands. So unless you force the operands to floats (as you do when you multiply with a float), a division of two integers will always return an integer: 1 / 2 = 0.
Â
Â
It can, however, be quite confusing when you encounter it for the first time
Even Guido van Rossum, the inventor of Python, admits it is too confusing and regrets having done it that way (seeÂ
http://python-history.blogspot.ch/2009/03/problem-with-integer-division.html). Incidentally, this is one of the fundamental behaviors to change in Python 3, in which you would get 1 / 2 = 0.5 without any further ado.
Â
Â
David