Process Module¶
process_with_tiles(ept_file, tile_size, output_path, metric, voxel_size, voxel_height=1, buffer_size=0.1, srs=None, hag=False, hag_dtm=False, dtm=None, bounds=None, interpolation=None, remove_outliers=False, outlier_mean_k=8, outlier_multiplier=3.0, cover_min_height=2.0, cover_k=0.5, pai_min_height=1.0, fhd_min_height=0.0, skip_existing=False, verbose=False, thin_radius=None, voxelgrid_cell=None, voxelgrid_mode='first', tile_indices=None, outliers_before_hag=False, rumple_min_height=None, rumple_resolution=None, rumple_method='two_triangle')
¶
Process a large EPT point cloud by tiling, compute CHM or other metrics for each tile, and write the results to the specified output directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ept_file
|
str
|
Path to the EPT file containing the point cloud data. |
required |
tile_size
|
tuple
|
Size of each tile as (tile_width, tile_height). |
required |
output_path
|
str
|
Directory where the output files will be saved. |
required |
metric
|
str
|
Metric to compute for each tile ("chm", "fhd", "pai", "cover", or "rumple"). |
required |
voxel_size
|
tuple
|
Voxel resolution as (x_resolution, y_resolution, z_resolution). |
required |
voxel_height
|
float
|
Height of each voxel in meters. Required if metric is "fhd", "pai", or "cover". |
1
|
buffer_size
|
float
|
Fractional buffer size relative to tile size (e.g., 0.1 for 10% buffer). Defaults to 0.1. |
0.1
|
srs
|
str
|
Spatial Reference System for the output. If None, uses SRS from the EPT file. |
None
|
hag
|
bool
|
If True, compute Height Above Ground using Delaunay triangulation. Defaults to False. |
False
|
hag_dtm
|
bool
|
If True, compute Height Above Ground using a provided DTM raster. Defaults to False. |
False
|
dtm
|
str
|
Path to the DTM raster file. Required if hag_dtm is True. |
None
|
bounds
|
tuple
|
Spatial bounds to crop the data. Must be of the form ([xmin, xmax], [ymin, ymax], [zmin, zmax]) or ([xmin, xmax], [ymin, ymax]). If None, tiling is done over the entire dataset. |
None
|
interpolation
|
str or None
|
Fill missing canopy heights for CHM or rumple using "linear", "cubic", "nearest", or None. For rumple, filling happens before the height mask and surface-area calculation. Other metrics do not use this option. Defaults to None. |
None
|
remove_outliers
|
bool
|
Whether to remove statistical outliers before calculating metrics. Defaults to False. |
False
|
outlier_mean_k
|
int
|
Number of nearest neighbors used by the statistical outlier filter. Used only when remove_outliers is True. Defaults to 8. |
8
|
outlier_multiplier
|
float
|
Standard deviation multiplier used by the statistical outlier filter. Used only when remove_outliers is True. Defaults to 3.0. |
3.0
|
cover_min_height
|
float
|
Height threshold (in meters) for canopy cover (used when metric == "cover"). Defaults to 2.0. |
2.0
|
cover_k
|
float
|
Beer–Lambert extinction coefficient for canopy cover. Defaults to 0.5. |
0.5
|
pai_min_height
|
float
|
Minimum height (m) to integrate PAI. Defaults to 1.0. |
1.0
|
fhd_min_height
|
float
|
Minimum height (m) to include in FHD entropy. Defaults to 0.0. |
0.0
|
skip_existing
|
bool
|
If True, skip tiles whose output file already exists. Defaults to False. |
False
|
verbose
|
bool
|
If True, print warnings for empty/invalid tiles and buffer adjustments. Defaults to False. |
False
|
thin_radius
|
float or None
|
If provided (> 0), apply Poisson radius-based thinning per tile before metrics. Units are in the same CRS as the data (e.g., meters). Defaults to None. |
None
|
voxelgrid_cell
|
float or None
|
If provided (> 0), apply PDAL voxel-grid downsampling per tile before metrics
using cell edge length of |
None
|
voxelgrid_mode
|
str
|
Representative selection for voxel-grid downsampling. Common values are "first" (keep first point unchanged) or "center" (snap kept point to voxel center). Defaults to "first". |
'first'
|
tile_indices
|
set[tuple[int, int]] or None
|
If provided, process only these zero-based tile indices while preserving the full tiling grid and buffer behavior. |
None
|
outliers_before_hag
|
bool
|
If True with remove_outliers=True, apply PDAL's statistical outlier filter and remove classification 7 points before HAG. This can avoid Delaunay failures caused by bad points. Defaults to False. |
False
|
rumple_min_height
|
float or None
|
Treat canopy heights strictly below this threshold as missing before calculating rumple. Defaults to None (use all finite heights). Missing heights follow rumple_method's rules and are not set to zero. |
None
|
rumple_resolution
|
float or tuple
|
Required when metric is "rumple". Output cell size, either a scalar or (dx, dy), in coordinate units. Each size must be a positive integer multiple of the corresponding XY voxel_size. The voxel sizes set the fine CHM resolution; rumple_resolution sets the area over which surface and ground areas are summed. Tile sizes must be multiples of the output resolution. Bounds are expanded to whole fine cells, and the output grid is anchored at their northwest corner and padded east and south to whole output cells. Padding contributes no area. Rumple tile indices start at the northwest corner (j=0 is northmost). At least one fine neighboring cell is read around each tile, even when buffer_size=0. With interpolation enabled, use a buffer wide enough to include samples around gaps: filling uses only the buffered tile and can differ from a whole-cloud calculation. |
None
|
rumple_method
|
str
|
Surface estimator and missing-data rule. Nonfinite and height-masked CHM values are treated as missing. "two_triangle" (default) splits each 2x2 CHM patch into two triangles and excludes patches with any missing height from both surface and ground area. "jenness" uses eight neighbors per cell: missing center cells are excluded, missing neighbors use the center height locally, and edge heights are repeated at the raster boundary. Cells without supported area produce NoData. |
'two_triangle'
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an unsupported metric is requested, if buffer or voxel sizes are invalid, or required arguments are missing. |
FileNotFoundError
|
If the EPT or DTM file does not exist, or a required file for processing is missing. |
Source code in pyforestscan/process.py
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 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 175 176 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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | |