Operations: Spatial aggregation of raster coverage

From ILWIS
Jump to: navigation, search
Main Page Arrow.png Operations
Spatial aggregation of raster coverage
Spatial aggregate of raster coverage

The Spatial aggregate of raster coverage operation aggregates blocks of input pixels by applying an aggregation function. The group size refers to the size of the blocks of input pixels on which an aggregation has to be performed. Aggregation functions refers to a method for calculating an output value for each block of input pixels. The following aggregation functions are available in ILWIS:

  • Average Calculates the average for each block of input pixel values
  • Count Counts the number of pixels in each block of input pixels that are not undefined
  • Maximum Finds the maximum for each block of input pixel values
  • Median Finds the median for each block of input pixels
  • Minimum Finds the minimum for each block of input pixel values
  • Predominant Finds the most occurring (predominant) class name, ID or value for each block of input pixels
  • Std Deviation Calculates the standard deviation for each block of input pixel values
  • Sum Calculates the sum for each block of input pixel values


The operation either creates a new georeference in which each block of input pixels corresponds to one output pixel (group) or the output raster map uses the same georeference as the input map (no group). All aggregation functions work on value maps. The aggregation functions Count, Median and Predominant also work on maps with another domain type. For the Median function, the order of a Class or ID domain is used.
The Spatial aggregate of raster coverage 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 input raster coverage, name of the aggregation method, a value for the size of group, defining whether change the geometry or use the input geometry for the output coverage)

Then, the Python syntax for the above mentioned operation is:


Aggregated raster=ilwis.Engine.do("aggregateraster", “file:///C:/my director/my raster", Aggregation Method, Groupsize, change geometry)


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/my raster.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:


Aggregateraster=ilwis.Engine.do( "aggregateraster", rc , "avg", 3, True)

Where “avg” refers to aggregate method “Average”, value 3 refers to group size 3 x 3 and “True” refers to change the geometry.

Figure 1, Spatial aggregation of raster coverage operation form


To start the Spatial aggregation of raster coverage operation from ILWIS main window:

Mar.jpg
  • Click the Operation tab on toolbar tabs
  • From the opened operation list select Spatial raster aggregation

Once the operation is selected from the list, an operation form will be opened in which you 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.

Input raster coverage: Enter an input raster coverage to be aggregated; use drag and drop.
Aggregation Method: Select an aggregate method from the dropdown list. The available methods are: Avg(Average), Max (Maximum), Med (Median), Min (Minimum), Pre (Predominant),or Sum (Summation).
Group size : Type a value for the size of the blocks of input pixels on which an aggregation function should be applied. For example, when you specify value 4, the aggregation is performed on each block of 4 x 4 input pixels. The Group size should be at least 2.
Change geometry : When selecting Yes each block of input pixels would appear as one pixel in the output map after the aggregation. The operation will create a new georeference which will obtain the same name as the output map. By selecting No the georeference of the input map and the output map should be the same: each aggregated value will be stored in all pixels in the output map which correspond to the considered block of input pixels.
Aggregated raster : Type a name for the output raster map that will contain the aggregated values.
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.