Class: Patches
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]));Properties Overview
| Name | Type | Description |
|---|---|---|
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. |
Methods Overview
| Method | Return Type | Description |
|---|---|---|
clear() |
void |
Removes all existing patches from the stand. |
createExtendedPatch(patchId, newPatchId) |
integer |
Creates a new patch by extending an existing patch. |
createFromGrid(grid) |
Array |
Creates patches from a raster grid. The grid is provided as a ScriptGrid object. |
createPatch(x, y, shape_string) |
boolean |
Creates a single patch with a specific shape at a given location. |
createRandomPatches(n) |
void |
Creates a given number of random patches within the stand. |
createRegular(size, spacing) |
Array |
Creates a regular pattern of patches (e.g., squares). |
createStrips(width, horizontal) |
Array |
Creates patches in the form of horizontal or vertical strips. |
lif(patch) |
double |
Calculates the average value of the Light Influence Field (LIF) at 4m height for a given patch. |
updateGrid() |
void |
This method is usually called automatically. It re-creates the internal 10x10m grid representation |
Properties Details
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.
Methods Details
clear()
Returns: void
Removes all existing patches from the stand.
createExtendedPatch(patchId, newPatchId)
Returns: integer
Creates a new patch by extending an existing patch. The new patch surrounds the existing patch with the given patchId.
Parameters:
patchId(integer): The ID of the existing patch to extend.newPatchId(integer): The ID for the new patch.
Return Value Description: The number of cells added to the new patch.
createFromGrid(grid)
Returns: Array
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:
grid(ScriptGrid): The input grid object.
Return Value Description: A list of the created Patch objects.
createPatch(x, y, shape_string)
Returns: boolean
Creates a single patch with a specific shape at a given location.
Parameters:
x(double): The x-coordinate (in meters) of the center of the shape.y(double): The y-coordinate (in meters) of the center of the shape.shape_string(string): A string defining the shape, e.g., “circle(15)” for a circle with a 15m radius, or “rect(20,30)” for a 20x30m rectangle.
Return Value Description: true if the patch was created successfully, false otherwise.
createRandomPatches(n)
Returns: void
Creates a given number of random patches within the stand. The patches are non-overlapping and cover the entire stand area.
Parameters:
n(integer): The number of random patches to create.
createRegular(size, spacing)
Returns: Array
Creates a regular pattern of patches (e.g., squares).
Parameters:
size(integer): The size of each patch in meters.spacing(integer): The spacing between patches in meters.
Return Value Description: A list of the created Patch objects.
createStrips(width, horizontal)
Returns: Array
Creates patches in the form of horizontal or vertical strips.
Parameters:
width(double): The width of the strips in meters.horizontal(boolean): Iftrue, horizontal strips are created, otherwise vertical strips.
Return Value Description: A list of the created Patch objects.
lif(patch)
Returns: double
Calculates the average value of the Light Influence Field (LIF) at 4m height for a given patch.
Parameters:
patch(Patch): The patch object for which to calculate the average LIF.
Return Value Description: The average LIF value for the patch.
updateGrid()
Returns: void
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.