# Operations: Binary math raster

  Binary math raster
 Binary math raster
 The Binary math raster operation can be used to perform arithmetic on raster maps. The operation includes: addition, subtraction, multiplication, division, modulus and exponential. Addition (Add); adds one raster coverage to another one or a certain value, given by user, to a raster coverage. Subtraction (Subtract); subtracts one raster coverage from another one or subtracts a certain value, given by user, from the raster coverage. Division (divide); divides a raster coverage to a certain value or to another raster coverage. Multiplication (times); multiplies two raster coverage or a certain value to a raster coverage. Modulus (Mod); finds the remainder after division of a raster coverage by another one or by a certain user defined value. Exponential (power); applied to two raster coverage's or a raster coverage and a number.The exponent of a number refers to how many times to use the number in a multiplication. As indicated above, these operators can be used to perform operation using two raster maps, a raster map and a number or two numbers. For example, users can add two raster maps (outmap = raster A + raser B ) or add certain value to a raster map (outmap = raster a + 21) generating a new raster map. In addition, the operation can also be used to add two values which generates a new number as an output but not a raster coverage. Note, for all the operators, when one or both operands are undefined, the output will also be undefined. As for the exponential operator, when the base value is negative, the exponent has to be integer value (otherwise the output will be undefined). Using the operator in the form of returns the nth root of a in power of m (). In case, using modulus (mod) operator, e.g.,  a mod b ;the output will be undefined if b is 0. The Binary math raster operation can be applied via ILWIS-Python editor or via ILWIS main window, Toolbar and the Operatins tab. The required Python syntax is: name of the output raster coverage = ilwis.Engine.do(name of the operation, name of an input raster coverage or a number, name of an input raster coverage or a number, operator) In example bellow, we subtract value 21 from a raster coverage; where the input raster coverage is tmb2, the value to be subtracted is 21, the operator is - (mines) and the name of the output raster coverage is tmb2c. tmb2c=ilwis.Engine.do('binarymathraster',“file:///C:/my director/tmb2.mpr", 21, "subtract") In general, the URL used in the Python syntax can be replaced with variable name created via using Python. For example: you can open a raster coverage or a georeference as variables and give them a name as the following: rc = ilwis.RasterCoverage("file:///C:/my director/tmb2.mpr") Once the variable is created via ILWIS-Python editor, then it can be used directly in Python syntax without quotation mark and the path as the following: tmb2c=ilwis.Engine.do('binarymathraster', rc, 21, "subtract") Or by using the Python operators directly: tmb2c = (rc - 21) Figure 1, Binary math raster operation form

To start the Binary math raster operation from ILWIS main window:

•  Click the Operation tab on toolbar tabs
•  From the opened operation list select Binary math raster

Once the Binary math raster operation is selected from the list, an operation form will be opened in which users can set parameters required for the operation including input(s), output(s), memory location and data format (Figure 1).
To successfully execute this operation, you need to complete the form with proper inputs data. The inputs data must be dragged from the catalog and dropped in their corresponding fields in the form or directly typed in.

Binary math raster operation form

 Raster or number: Enter either an input value or a raster coverage using drag and drop or type in the name of the map or a value. Note, in order to generate an output raster coverage, one of the two inputs has to be a raster coverage. Raster or number: Enter an input raster coverage using drag and drop or type a value. Operator: Select an operator from the list to be used in the operation. When input(s) is a raster coverage, the selected operator is applied to each pixel. Raster coverage: Type a name for the output raster coverage. Output format: Select a format from the list to save the output raster map. The default format is Memory; if you select it, the output will be temporally saved in the internal catalog and will be removed when you exit the program. If you select other format, the output will be saved in the active catalog. Execute: Click the execute button to run this operation.