The Binary math features operation can be used to perform arithmetic on feature coverages (vector data). Currently, the operation includes two operators: addition and subtraction.
- Addition (Add); adds features of one feature coverage to another one.
- Subtraction (Subtract); subtracts features of one feature coverage from another one when feature geometry is exactly the same.
As indicated above, these operators can be used to perform operation on two feature coverages. For example, adding a point map to a polygon map generate a map that includes all the polygon and point features; e.g.,(
feature C = feature A + feature B ). On the other hand, subtraction of the output of adding operation (feature C) from one of the original map (feature A or feature B) will reproduce the original map; e.g., feature A' = feature C - feature B. The output map of the subtraction operation(feature A') is exactly the same as the map feature A. Note at the moment, only adding operation includes the attribute; meaning as the result of the operation the attributes of the two input maps will be joined and be associated with the output of the operation.
The Binary math feature 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 feature coverage = ilwis.Engine.do(name of the operation, name of the first input feature coverage, name of the second input feature coverage, Operator)
In example bellow, we add a point feature coverage to a polygon feature coverage; where the first feature coverage is point.mpa, the second feature coverage is polygon.mpa, the operator is add and the name of the output raster coverage is polypoint.
- “file:///C:/my dir/point.mpa", “file:///C:/my dir/polygon.mpa", "add")
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:
fc1 = ilwis.RasterCoverage("file:///C:/mydir/point.mpa")
fc2 = ilwis.RasterCoverage("file:///C:/mydir/polygon.mpa")
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:
polypoint=ilwis.Engine.do("binarymathraster", fc1, fc2, "add")