Class: SpatialAnalysis
The SpatialAnalysis class encapsulates special spatial analysis operations in iLand. For example, the class contains methods to conduct patch size analysis, or calculate the Rumple index.
You can create an instance of this class using the newoperator: new SpatialAnalysis().
Example
// create an object (only once)
var spatial_analysis = new SpatialAnalysis();
// save data
spatial_analysis.saveRumpleGrid('temp/rumple.asc');Properties Overview
| Name | Type | Description |
|---|---|---|
patchsizes |
array |
The patchsizes property provides a list of with the number of pixels of each extracted patch in a prior call to See also: patches(). |
rumpleIndex |
double |
Retrieve the rumple index for the full landscape (i.e., one value). |
Methods Overview
| Method | Return Type | Description |
|---|---|---|
patches(grid, min_size) |
void |
Perform a patch analysis on the input grid and return a Grid with unique patch IDs |
saveCrownCoverGrid(filename) |
void |
Generate a map of the crown cover ( at 2m resolution), and save an average (100m) to filename (ESRI ASCII format). |
saveCrownCoverGrid(filename, mask) |
void |
Generate a map of the crown cover ( at 2m resolution), and save an average to filename (ESRI ASCII format). |
saveRumpleGrid(filename) |
void |
Calculate the Rumple-Index for the landscape with a spatial resolution of 10m (i.e., the cells of the iLand height grid) |
Properties Details
patchsizes
array
The patchsizes property provides a list of with the number of pixels of each extracted patch in a prior call to See also: patches(). The first entry of the array is the number of pixels of the patch ID 1, etc.
See also: patches()
// let 'wind_grid' be a grid of wind damages, non-zero pixels had some kind of damage (the damage map has a 10m resolution)
// now run the patch analysis and keep damaged areas >4 px
wind_grid = SpatialAnalysis.patches(wind_grid, 5);
// save the patches grid to the output directory and a user code given in the XML file
wind_grid.save( Globals.defaultDirectory('output') + Globals.setting('user.code')+ '_stormDamage_v' + v + '.asc' );
// save also a list of the extracted patch sizes
Globals.saveTextFile(Globals.defaultDirectory('output') + Globals.setting('user.code')+ '_stormPatches_v' + v + '.txt', SpatialAnalysis.patchsizes + "\n");rumpleIndex
double
Retrieve the rumple index for the full landscape (i.e., one value).
See also: saveRumpleGrid()
Methods Details
patches(grid, min_size)
Returns: void
Perform a patch analysis on the input grid and return a Grid with unique patch IDs assigned to each patch (starting with 1, 2, 3, …). A ‘patch’ is a number of adjacent pixels with a value > 0. In other words, all connected non-zero areas are flagged with unique Ids in the output grid. Internally, a simple flood-fill algorithm searching in the Moore-neighborhood (8 neighbors) is used and applied repeatedly.
If a patch has a size which is smaller than min_size, the cells of the grid are set to 0, and the patch is not recorded. A list of all patches (and patchsizes) is available with the patchsizes property.
See also: patchsizes
Parameters:
grid(Grid): grid to analyzemin_size(integer): ignore patches with an area belowmin_sizepixels.
saveCrownCoverGrid(filename)
Returns: void
Generate a map of the crown cover ( at 2m resolution), and save an average (100m) to filename (ESRI ASCII format). For each tree, the tree crown (as defined by the ‘reader’ stamp, which defines for 2m pixels the share of pixels that are covered by the crown) is additively plotted on a 2m grid. If that sum is larger then 0.5 (i.e. 50%), a pixel is consiedered as ‘covered’. The resulting grid provides for each 100m cell a fraction of ‘covered’ pixels. Note that 2m cells that are out of the project area are not counted (i.e., the resulting crown cover refers only to the stockable area of the resource unit).
Parameters:
filename(string): target filename (relative to project folder)
saveCrownCoverGrid(filename, mask)
Returns: void
Generate a map of the crown cover ( at 2m resolution), and save an average to filename (ESRI ASCII format). For each tree, the tree crown (as defined by the ‘reader’ stamp, which defines for 2m pixels the share of pixels that are covered by the crown) is additively plotted on a 2m grid. If that sum is larger then 0.5 (i.e. 50%), a pixel is consiedered as ‘covered’. The grid is used as a mask: the resulting grid uses the cell size of grid and also the spatial extent. The resulting grid provides for each 100m cell a fraction of ‘covered’ pixels.
Parameters:
filename(string): target filename (relative to project folder)mask(Grid): (a Grid
Example:
// create a grid:
var mask = new Grid();
mask.create(100, 60, 10); // cell-size 10m, 100 x 60 cells
mask.setOrigin(100,1020); // define the origin, the grid covers (100/1020)-(1100/1620)
SpatialAnalysis.saveCrownCoverGrid('temp/test.asc', mask); // save the crown cover gridsaveRumpleGrid(filename)
Returns: void
Calculate the Rumple-Index for the landscape with a spatial resolution of 10m (i.e., the cells of the iLand height grid) and extract a 100m grid (average over the 10m cells). Store the grid to filename (ESRI ASCII format).
The Rumple-Index is a spatial index relating surface area to ground area. In forestry, it is a indicator of vertical heterogeneity. In iLand, the Rumple Index is the variability of the maximum tree height on 10m level (i.e. the “Height”-Grid). The RumpleIndex is calculated for each resource unit and also for the full project area.
See also: rumpleIndex
Parameters:
filename(string): target filename (relative to project folder)