Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1194 werner 1
 
2
/**
3
The `SpatialAnalysis` class encapsulates special spatial analysis operations in iLand. For example, the class
4
contains methods to conduct patch size analysis, or calculate the Rumple index.
5
 
6
An instance of the object is available in the global Javascript context with the name `SpatialAnalysis`.
7
 
8
Example
9
-------
10
    SpatialAnalysis.saveRumpleGrid('temp/rumple.asc');
11
 
12
@module iLand
13
@class SpatialAnalysis
14
 */
15
 
16
 
17
/**
1204 werner 18
Retrieve the rumple index for the full landscape (i.e., one value).
1194 werner 19
 
20
See also: {{#crossLink "SpatialAnalysis/saveRumpleGrid:method"}}{{/crossLink}}
21
 
22
@property rumpleIndex
23
@type double
24
*/
25
 
26
/**
27
Generate a map of the crown cover ( at 2m resolution), and save an average (100m) to `filename` (ESRI ASCII format).
28
For each tree, the tree crown (as defined by the ['reader' stamp](http://iland.boku.ac.at/Lightroom), which defines for 2m pixels the share
29
of pixels that are covered by the crown) is additively plotted on a 2m grid.
30
If that sum is larger then 0.5 (i.e. 50%), a pixel is consiedered as 'covered'.
31
The resulting grid provides for each 100m cell a fraction of 'covered' pixels.
32
 
33
@method saveCrownCoverGrid
34
@param {string} filename target filename (relative to project folder)
35
*/
36
 
37
/**
38
Calculate the Rumple-Index for the landscape with a spatial resolution of 10m (i.e., the cells of the iLand height grid)
39
and extract a 100m grid (average over the 10m cells). Store the grid to `filename` (ESRI ASCII format).
40
 
41
The Rumple-Index is a spatial index relating surface area to ground area.
42
In forestry, it is a indicator of vertical heterogeneity. In iLand, the Rumple Index is
43
the variability of the maximum tree height on 10m level (i.e. the "Height"-Grid).
44
The RumpleIndex is calculated for each resource unit and also for the full project area.
45
 
46
See also: {{#crossLink "SpatialAnalysis/rumpleIndex:property"}}{{/crossLink}}
47
 
48
@method saveRumpleGrid
49
@param {string} filename target filename (relative to project folder)
50
*/
51
 
52
/**
53
Perform a patch analysis on the input `grid` and return a {{#crossLink "Grid"}}{{/crossLink}} with unique patch IDs
54
assigned to each patch (starting with 1, 2, 3, ...). A 'patch' is a number of adjacent pixels with a value > 0. In other words,
55
all connected non-zero areas are flagged with unique Ids in the output grid.
56
Internally, a simple flood-fill algorithm searching in the Moore-neighborhood (8 neighbors) is used and applied repeatedly.
57
 
58
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
59
patches (and patchsizes) is available with the {{#crossLink "SpatialAnalysis/patchsizes:property"}}{{/crossLink}} property.
60
 
61
 
62
See also: {{#crossLink "SpatialAnalysis/patchsizes:property"}}{{/crossLink}}
63
 
64
@method patches
65
@param {Grid} grid grid to analyze
66
@param {integer} min_size ignore patches with an area below `min_size` pixels.
67
*/
68
/**
69
The `patchsizes` property provides a list of with the number of pixels of each extracted patch in a prior call to  See also: {{#crossLink "SpatialAnalysis/patches:method"}}{{/crossLink}}.
70
The first entry of the array is the number of pixels of the patch ID 1, etc.
71
 
72
See also: {{#crossLink "SpatialAnalysis/patches:method"}}{{/crossLink}}
73
 
74
@property patchsizes
75
@type array[integer]
76
@Example
77
    // let 'wind_grid' be a grid of wind damages, non-zero pixels had some kind of damage (the damage map has a 10m resolution)
78
    // now run the patch analysis and keep damaged areas >4 px
79
    wind_grid = SpatialAnalysis.patches(wind_grid, 5);
80
    // save the patches grid to the output directory and a user code given in the XML file
81
    wind_grid.save( Globals.defaultDirectory('output') + Globals.setting('user.code')+ '_stormDamage_v' + v + '.asc' );
82
    // save also a list of the extracted patch sizes
83
    Globals.saveTextFile(Globals.defaultDirectory('output') + Globals.setting('user.code')+ '_stormPatches_v' + v + '.txt', SpatialAnalysis.patchsizes + "\n");
84
 
85
*/
86
 
87
SpatialAnalysis = {
88
}