Patches Class
ABE\abe_patches.js:1
The patches object provides functions to create and manage spatial sub-divisions (patches) within a forest stand.
Patches are defined on a 10x10m grid. They can be used for spatially explicit forest management.
Use the patches property of the (current) stand variable to access the functionality.
// create 2 random patches
stand.patches.createRandomPatches(2);
// get the list of patches
var patch_list = stand.patches.list;
// get the light influence field for the first patch
log("LIF of first patch: " + stand.patches.lif(patch_list[0]));
Item Index
Methods
Methods
clear
()
Removes all existing patches from the stand.
createExtendedPatch
-
patchId -
newPatchId -
[grow_by=1]
Creates a new patch by extending an existing patch.
The new patch surrounds the existing patch with the given patchId.
Parameters:
-
patchIdIntegerThe ID of the existing patch to extend.
-
newPatchIdIntegerThe ID for the new patch.
-
[grow_by=1]Integer optionalThe distance (in 10m cells) to extend the patch by.
Returns:
The number of cells added to the new patch.
createFromGrid
-
grid
Creates patches from a raster grid. The grid is provided as a ScriptGrid object. For each unique value in the grid, a corresponding patch is created.
Parameters:
-
gridScriptGridThe input grid object.
Returns:
A list of the created Patch objects.
createPatch
-
x -
y -
shape_string -
[id=-1]
Creates a single patch with a specific shape at a given location.
Parameters:
-
xDoubleThe x-coordinate (in meters) of the center of the shape.
-
yDoubleThe y-coordinate (in meters) of the center of the shape.
-
shape_stringStringA string defining the shape, e.g., "circle(15)" for a circle with a 15m radius, or "rect(20,30)" for a 20x30m rectangle.
-
[id=-1]Integer optionalThe ID for the new patch. If -1, a new unique ID is generated.
Returns:
true if the patch was created successfully, false otherwise.
createRandomPatches
-
n
Creates a given number of random patches within the stand. The patches are non-overlapping and cover the entire stand area.
Parameters:
-
nIntegerThe number of random patches to create.
createRegular
-
size -
spacing
Creates a regular pattern of patches (e.g., squares).
Parameters:
-
sizeIntegerThe size of each patch in meters.
-
spacingIntegerThe spacing between patches in meters.
Returns:
A list of the created Patch objects.
createStrips
-
width -
horizontal
Creates patches in the form of horizontal or vertical strips.
Parameters:
-
widthDoubleThe width of the strips in meters.
-
horizontalBooleanIf
true, horizontal strips are created, otherwise vertical strips.
Returns:
A list of the created Patch objects.
lif
-
patch
Calculates the average value of the Light Influence Field (LIF) at 4m height for a given patch.
Parameters:
-
patchPatchThe patch object for which to calculate the average LIF.
Returns:
The average LIF value for the patch.
updateGrid
()
This method is usually called automatically. It re-creates the internal 10x10m grid representation
of the patches from the list of patch objects. You might need to call this if you have manipulated
the list of patches manually.
Properties
list
Array
A list containing all Patch objects of the current stand.
rectangle
Object
The bounding rectangle of the stand in meters. This is a read-only property.
The rectangle object has x, y, width, and height properties.
The iLand Javascript API