samstars.data.tiling¶
samstars.data.tiling
¶
Prepare aligned imagery, canopy heights, cost rasters, and crown seeds.
build_single_tile(*, img, chm, den, crowns=None, rgb_bands=None, nir_band=None, texture_band=None, slic=None, out=Path('tiles'), tile_name='tile_000_000', cost_weights=(0.4, 0.3, 0.3, 0.0), seed_params=None, thin_seeds=True, thin_dist=0.8, seed_d_min=4.5, seed_min_dist_px=4, seed_gauss_sigma=2, seed_min_samples=1, seed_merge_radius=3.0, seed_min_canopy_height=2.0, write_den=False, skip_existing=True)
¶
Prepare one scene as a tile and return its parent directory.
Uses the same band selection, alignment, and seed controls as build_tiles.
crowns, when supplied, is copied into the tile as crowns.gpkg for training.
The entire scene is processed as one tile; use build_tiles for larger areas.
Source code in samstars/data/tiling.py
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 | |
build_tiles(*, img, chm, den, rgb_bands=None, nir_band=None, texture_band=None, slic=None, out=Path('tiles'), tile=500.0, overlap=20.0, cost_weights=(0.4, 0.3, 0.3, 0.0), seed_params=None, thin_seeds=True, thin_dist=0.8, seed_d_min=4.5, seed_min_dist_px=4, seed_gauss_sigma=2, seed_min_samples=1, seed_merge_radius=3.0, seed_min_canopy_height=2.0, write_den=False, skip_existing=True)
¶
Align lidar rasters to imagery and prepare overlapping segmentation tiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
Path
|
Three-band RGB or multiband imagery with square pixels. |
required |
chm
|
Path
|
Canopy heights in meters; resampled to the imagery grid if needed. |
required |
den
|
Path
|
First-return counts or density, using the same units as training. |
required |
rgb_bands
|
tuple[int, int, int] | None
|
One-based red, green, blue indices; defaults to |
None
|
nir_band
|
int | None
|
Optional near-infrared band for the NDVI cost term. |
None
|
texture_band
|
int | None
|
Optional texture band; otherwise use the mean RGB intensity. |
None
|
out
|
Path
|
Parent directory for |
Path('tiles')
|
tile
|
float
|
Tile width and height in imagery CRS units, normally meters. |
500.0
|
overlap
|
float
|
Overlap between neighboring tiles, in the same units as |
20.0
|
cost_weights
|
tuple[float, float, float, float]
|
Height-edge, NDVI-gap, texture, and experimental SLIC weights. |
(0.4, 0.3, 0.3, 0.0)
|
seed_params
|
SeedParams | None
|
Optional complete seed configuration; overrides seed controls. |
None
|
thin_seeds
|
bool
|
Reduce closely spaced seed points after detection. |
True
|
thin_dist
|
float
|
Minimum seed spacing in projected CRS units. |
0.8
|
seed_d_min
|
float
|
Minimum peak value in the CHM and density rasters. |
4.5
|
seed_min_dist_px
|
int
|
Peak-search radius in pixels. |
4
|
seed_gauss_sigma
|
int
|
Gaussian smoothing scale in pixels. |
2
|
seed_merge_radius
|
float
|
Candidate grouping distance in projected CRS units. |
3.0
|
seed_min_canopy_height
|
float
|
Minimum canopy height in meters. |
2.0
|
write_den
|
bool
|
Also save the aligned density raster in each tile. |
False
|
skip_existing
|
bool
|
Reuse complete tile folders. Set to False after changing inputs or preparation settings, or use a new output directory. |
True
|
Each nonempty tile contains img.tif, chm.tif, cost.tif, and seeds.gpkg.
Source code in samstars/data/tiling.py
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 | |