06-14-2018 01:46 PM
HI. I'm trying to create a model that multiplies two thematic rasters together, then evalutes the product with an Either/Or operator, either keeping one of the product values, or reverting to one of the orignial input values, as the "Otherwise" value. The model runs, but applies the "Output if True" value to almost everything, which it shouldn't (there should be a range of values btw 1-6, and 9).
I don't find any explanation of the correct syntax for the "Test" used in the Either/or. Can i specify an integer value from the Multiply operator? or is the "Test" always the result of a previous Boolean operator?
I've appreciated the help I've received already, and will appreciate any suggestions for correcting my errors.
I'm pasting the model I have, and the way I currently have teh Either/Or properties set up.
06-15-2018 01:23 AM
I see what you mean, there is no explaination of the test port. In this case I believe it does only accept boleean/binary inputs as it states that it transforms the test into a binary. This does make sense as there is only 2 following options, Input 1 or Input 2. If you wanted more than 2 output options you would probably require the Pick operator, or perhaps the Critera.
To do what you want I believe you would need to use a Eq operator begore the test, as shown below. This snippet replaces all pixels from the Raster Input with the value of 9 to a value of 0, anything else remains as the orginal values.
Hope that helps!
06-18-2018 06:52 AM - edited 06-18-2018 07:05 AM
An "is true" test in Spatial Modeler will evaluate pretty much anything input on the test port to be "false" if the value is 0 and "true" if it is anything else.
So if you were inputting a raster layer, each pixel is evaluated. If the DN value is 0 the test is false. If the value is 1, or 24, or 255, or -16, etc., it's true.
Of course normally you'd do what Emily suggests - use some other Operator first to produce a truly boolean value to input to the test port. So you could test to see if DN values are Greater Than 0, for example, which will return a true (1) or false (0) for every pixel. That can then be passed to the Test port.
So I think your model needs to look like the following (cleaned up a bit so you dont need that intermediary raster output and so that Preview will work without needing to write a file out to disk first):