Calculate Module¶
assign_voxels(arr, voxel_resolution)
¶
Assigns voxel grids to spatial data points based on the specified resolutions.
:param arr: Input array-like object containing point cloud data with 'X', 'Y', and 'HeightAboveGround' fields. :type arr: numpy.ndarray :param voxel_resolution: The resolution for x, y, and z dimensions of the voxel grid. :type voxel_resolution: tuple of floats
:return: A tuple containing the histogram of the voxel grid (with corrected orientation) and the extent of the point cloud. :rtype: tuple of (numpy.ndarray, list)
Source code in pyforestscan/calculate.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
calculate_chm(arr, voxel_resolution, interpolation='linear')
¶
Calculate Canopy Height Model (CHM) for a given voxel size. The height is the highest HeightAboveGround value in each (x, y) voxel.
:param arr: Input array-like object containing point cloud data with 'X', 'Y', and 'HeightAboveGround' fields. :type arr: numpy.ndarray :param voxel_resolution: The resolution for x and y dimensions of the voxel grid. :param interpolation: Method for interpolating pixel gaps in the CHM. Supported methods are: "nearest", "linear", "cubic", or None. If None, no interpolation is performed. :type voxel_resolution: tuple of floats (x_resolution, y_resolution)
:return: A tuple containing the CHM as a 2D numpy array and the spatial extent. :rtype: tuple of (numpy.ndarray, list)
Source code in pyforestscan/calculate.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
calculate_fhd(voxel_returns)
¶
Calculate the Foliage Height Diversity (FHD) for a given set of voxel returns.
This function computes Foliage Height Diversity by calculating the entropy of the voxel return proportions along the z-axis, which represents vertical structure in the canopy.
:param voxel_returns: A numpy array of shape (x, y, z) representing voxel returns, where x and y are spatial dimensions, and z represents height bins (or layers along the vertical axis).
:return: A numpy array of shape (x, y) representing the FHD values for each (x, y) location. Areas with no voxel returns will have NaN values.
Source code in pyforestscan/calculate.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
calculate_pad(voxel_returns, voxel_height, beer_lambert_constant=None)
¶
Calculate the Plant Area Density (PAD) using the Beer-Lambert Law.
:param voxel_returns: numpy array representing the returns from each voxel (x, y, z). :param voxel_height: float, height of each voxel. :param beer_lambert_constant: Optional Beer-Lambert constant, defaults to 1 if not provided.
:return: numpy array containing PAD values for each voxel.
Source code in pyforestscan/calculate.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
calculate_pai(pad, min_height=1, max_height=None)
¶
Calculate Plant Area Index (PAI) from PAD data by summing LAD values across the Z (height) axis.
:param pad: A 3D numpy array representing the Plant Area Density (PAD) values. :param min_height: Minimum height index for summing PAD values (optional). :param max_height: Maximum height index for summing PAD values (optional).
:return: A 2D numpy array with PAI values for each (x, y) voxel column.
Source code in pyforestscan/calculate.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
generate_dtm(ground_points, resolution=2.0)
¶
Generates a Digital Terrain Model (DTM) raster from classified ground points.
:param ground_points: list Point cloud arrays of classified ground points. :type ground_points: list :param resolution: float, spatial resolution of the DTM in meters. :return: tuple A tuple containing the DTM as a 2D NumPy array and the spatial extent [x_min, x_max, y_min, y_max]. :rtype: tuple (numpy.ndarray, list) :raises ValueError: If no ground points are found for DTM generation. :raises KeyError: If point cloud data is missing 'X', 'Y', or 'Z' fields.
Source code in pyforestscan/calculate.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|