Operations: Binary math features

From ILWIS
Jump to: navigation, search
Main Page Arrow.png Operations
Binary math features
Binary math features

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.


polypoint=ilwis.Engine.do("binarymathfeature",
“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")

Figure 1, Binary math feature operation form



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

Mar.jpg
  • Click the Operation tab on toolbar tabs
  • From the opened operation list select Binary math feature

Once the Binary math feature 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), operatore, 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 feature operation form

First input feature coverage: Enter a feature coverage using drag and drop or type in the name of the map.
Second feature coverage: Enter a feature coverage using drag and drop or type in the name of the map.
Operator: Select one of the two available operators to be used in the operation.
Output feature coverage: Type a name for the output feature 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.