The Raster selection operation allows user to select parts of the spatial extent or attributes of a raster coverage in order to generate a coverage that include only data (spatial and tabular) representing the selected features. To run the select raster operation and clipped regions, attributes or logical constraints, it is required for users to define a selection based on their interests following the formal definition which is:
(logical-attribute-comparison)? ( and | or logical-attribute-comparison )* (with: (data-selection) (and (data-selection)*)?
Where, ? means the output includes 0 and 1 and the * means the output contains 0 and more.
Logical-attribute-comparison includes attribute, logical operators (<|>|<=|>=|==) and appropriate-value (special attribute for raster coverages such as imageries is pixel value).
For raster coverages without attribute tables the Data-selection includes envelope-definition which can be presented as a bounding box-definition or polygon-definition.
The syntax for the Envelope-definition is: envelope(min x, min y, max x, max y) where min and max are coordinates.
The syntax for Bounding box-definition is: boundingbox(min x, min y, max x, max y) where min x and y are rows and columns.
The syntax for the Polygon-definitions is based on wkt (well-known-text) polygon definition: (“POLYGON (min x, min y, max x, max y)”). For segment or point selection the same syntax can be used by replacing POLYGON with SEGMENT or POINT respectively.
In case of attribute definition the general syntax is: attributes (<attribute-name> (,attribute-name>)*).
Note that in case of raster coverages and only one attribute is selected, no attribute table will be attached to the output.
The examples bellow illustrate number of selection-definitions to generate a selection output from an existing raster coverage with pH, and topology as its attributes:
- Select(myraster,”pH > 4”) // logical-attribute selection
- Select(myraster, ”pH > 4 and pH < 7”) // logical-attribute selection
- Select(myraster,”PH>4 or topology==flat”) // logical-attribute selection
- Select(myraster,”boundingbox(20 20, 300 250)”) // data-selection by clipping
- Select(myraster,”PH > 6 with: boundingbox(20 20, 300 250)”) // logical-attribute selection and a data-selection
- Select(myraster,”PH>6 with: boundingbox(20 20, 300 250) and attributes(topology)”) // logical-attribute selection and a two data-selections
- Select(myraster,”pixelvalue < 100”) // logical-attribute-selection with pixelvalues (usually used with images)
Note that the double quotes are mandatory.
The Raster selection 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 the input raster coverage, selection-definition)
Then, the Python syntax for the above mentioned operation is:
output raster = ilwis.Engine.do("selection", “file:///C:/my director/myraster.mpr”, “selection-definition")
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 as a variable and give it a name as the following example:
rc = ilwis.RasterCoverage("file:///C:/my director/myraster.mpr")
Once these variable is created via ILWIS-Python editor, then they can be used directly in Python syntax without quotation mark and the path as the following:
output = ilwis.Engine.do("selection", rc, "selection-definition")