Show:
Defined in: ABE\abe_patches.js:1
Module: ABE

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]));

Methods

clear

()

Removes all existing patches from the stand.

createExtendedPatch

(
  • patchId
  • newPatchId
  • [grow_by=1]
)
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.

  • [grow_by=1] Integer optional

    The distance (in 10m cells) to extend the patch by.

Returns:

Integer:

The number of cells added to the new patch.

createFromGrid

(
  • grid
)
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.

Returns:

Array:

A list of the created Patch objects.

createPatch

(
  • x
  • y
  • shape_string
  • [id=-1]
)
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.

  • [id=-1] Integer optional

    The ID for the new patch. If -1, a new unique ID is generated.

Returns:

Boolean:

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:

  • n Integer

    The number of random patches to create.

createRegular

(
  • size
  • spacing
)
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.

Returns:

Array:

A list of the created Patch objects.

createStrips

(
  • width
  • horizontal
)
Array

Creates patches in the form of horizontal or vertical strips.

Parameters:

  • width Double

    The width of the strips in meters.

  • horizontal Boolean

    If true, horizontal strips are created, otherwise vertical strips.

Returns:

Array:

A list of the created Patch objects.

lif

(
  • patch
)
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.

Returns:

Double:

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.