Operations: Raster selection

From ILWIS
Jump to: navigation, search
Main Page Arrow.png Operations
Raster selection
Raster selection

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")


Figure 1, Raster selection operation form




To start the Raster selection operation from ILWIS main window:

Mar.jpg
  • Click the Operation tab on toolbar tabs
  • From the opened operation list select Polygon to raster map


Once the Raster selection operation is selected from the list, an operation form will be opened in which you can set parameters required for that 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 typed in.

input raster coverage: Select an input raster coverage to be clipped.

selection-definition : Type in a selection-definition following the formal definition as illustrated in the earlier examples.

output raster coverage: Type a name for the output raster map that will contain rasterized pixels.

Output format: Select a format 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.