You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
buffer: Overlapping buffer of tiles in meters (UTM)
107
-
tile_width: Tile width in meters
108
-
tile_height: Tile height in meters
109
-
dtype_bool: Flag to edit dtype to prevent black tiles
110
-
minx: Minimum x coordinate of tile
111
-
miny: Minimum y coordinate of tile
112
-
crs: Coordinate reference system
113
-
tilename: Name of the tile
104
+
img_path: Path to the orthomosaic.
105
+
out_dir: Output directory.
106
+
buffer: Overlapping buffer of tiles in meters (UTM).
107
+
tile_width: Tile width in meters.
108
+
tile_height: Tile height in meters.
109
+
dtype_bool: Flag to edit dtype to prevent black tiles.
110
+
minx: Minimum x coordinate of the tile.
111
+
miny: Minimum y coordinate of the tile.
112
+
crs: Coordinate reference system.
113
+
tilename: Name of the tile.
114
+
crowns: Crown polygons as a GeoDataFrame used to skip tiles if coverage is below `threshold`.
115
+
threshold: Minimum fraction [0,1] of tile coverage by `crowns` required to avoid skipping the tile.
116
+
nan_threshold: Maximum proportion [0,1] of the tile that can be nodata or NaN values before skipping.
117
+
mask_gdf: A GeoDataFrame containing polygons tile act as masks for the tile. Only the interior is kept, the rest of the image will become nodata.
118
+
additional_nodata: List of additional pixel values to treat as nodata.
119
+
image_statistics: A list of dictionaries where each dictionary contains information about the pixel distribution of that band. One list element per band.
"""Process a single multispectral tile for making predictions.
233
239
234
240
Args:
235
-
img_path: Path to the orthomosaic
236
-
out_dir: Output directory
237
-
buffer: Overlapping buffer of tiles in meters (UTM)
238
-
tile_width: Tile width in meters
239
-
tile_height: Tile height in meters
240
-
dtype_bool: Flag to edit dtype to prevent black tiles
241
-
minx: Minimum x coordinate of tile
242
-
miny: Minimum y coordinate of tile
243
-
crs: Coordinate reference system
244
-
tilename: Name of the tile
241
+
img_path: Path to the orthomosaic.
242
+
out_dir: Output directory.
243
+
buffer: Overlapping buffer of tiles in meters (UTM).
244
+
tile_width: Tile width in meters.
245
+
tile_height: Tile height in meters.
246
+
dtype_bool: Flag to edit dtype to prevent black tiles.
247
+
minx: Minimum x coordinate of the tile.
248
+
miny: Minimum y coordinate of the tile.
249
+
crs: Coordinate reference system.
250
+
tilename: Name of the tile.
251
+
crowns: Crown polygons as a GeoDataFrame used to skip tiles if coverage is below `threshold`.
252
+
threshold: Minimum fraction [0,1] of tile coverage by `crowns` required to avoid skipping the tile.
253
+
nan_threshold: Maximum proportion [0,1] of the tile that can be nodata or NaN values before skipping.
254
+
mask_gdf: A GeoDataFrame containing polygons tile act as masks for the tile. Only the interior is kept, the rest of the image will become nodata.
255
+
additional_nodata: List of additional pixel values to treat as nodata.
256
+
image_statistics: A list of dictionaries where each dictionary contains information about the pixel distribution of that band. One list element per band.
245
257
246
258
Returns:
247
259
None
@@ -356,19 +368,24 @@ def process_tile_train(
356
368
"""Process a single tile for training data.
357
369
358
370
Args:
359
-
img_path: Path to the orthomosaic
360
-
out_dir: Output directory
361
-
buffer: Overlapping buffer of tiles in meters (UTM)
362
-
tile_width: Tile width in meters
363
-
tile_height: Tile height in meters
364
-
dtype_bool: Flag to edit dtype to prevent black tiles
365
-
minx: Minimum x coordinate of tile
366
-
miny: Minimum y coordinate of tile
367
-
crs: Coordinate reference system
368
-
tilename: Name of the tile
369
-
crowns: Crown polygons as a geopandas dataframe
370
-
threshold: Min proportion of the tile covered by crowns to be accepted {0,1}
371
-
nan_theshold: Max proportion of tile covered by nans
371
+
img_path: Path to the orthomosaic.
372
+
out_dir: Output directory.
373
+
buffer: Overlapping buffer of tiles in meters (UTM).
374
+
tile_width: Tile width in meters.
375
+
tile_height: Tile height in meters.
376
+
dtype_bool: Flag to edit dtype to prevent black tiles.
377
+
minx: Minimum x coordinate of tile.
378
+
miny: Minimum y coordinate of tile.
379
+
crs: Coordinate reference system.
380
+
tilename: Name of the tile.
381
+
crowns: Crown polygons as a geopandas DataFrame.
382
+
threshold: Min proportion of the tile covered by crowns to be accepted {0,1}.
383
+
nan_threshold: Max proportion of tile covered by NaNs.
384
+
mode: Type of the raster data ("rgb" or "ms").
385
+
class_column: Name of the column in `crowns` DataFrame for class-based tiling.
386
+
mask_gdf: A GeoDataFrame containing polygons tile act as masks for the tile. Only the interior is kept, the rest of the image will become nodata.
387
+
additional_nodata: List of additional pixel values to treat as nodata.
388
+
image_statistics: A list of dictionaries where each dictionary contains information about the pixel distribution of that band. One list element per band.
Calculate statistics for a raster using either whole image or sampled windows.
534
+
"""Calculate statistics for a raster using either whole image or sampled windows.
519
535
520
-
Parameters:
521
-
- file_path: str, path to the raster file.
522
-
- values_to_ignore: list, values to ignore in statistics (e.g., NaN, custom values).
523
-
- window_size: int, size of square window for sampling.
524
-
- min_windows: int, minimum number of valid windows to include in statistics.
536
+
Args:
537
+
file_path: str, path to the raster file.
538
+
values_to_ignore: list, values to ignore in statistics (e.g., NaN, custom values).
539
+
window_size: int, size of square window for sampling.
540
+
min_windows: int, minimum number of valid windows to include in statistics.
541
+
mode: str, type of the raster data ("rgb" or "ms").
525
542
526
543
Returns:
527
-
- List of dictionaries containing statistics for each band.
544
+
List of dictionaries containing statistics for each band.
528
545
"""
529
546
ifvalues_to_ignoreisNone:
530
547
values_to_ignore= []
@@ -632,26 +649,32 @@ def tile_data(
632
649
) ->None:
633
650
"""Tiles up orthomosaic and corresponding crowns (if supplied) into training/prediction tiles.
634
651
635
-
Tiles up large rasters into manageable tiles for training and prediction. If crowns are not supplied, the function
636
-
will tile up the entire landscape for prediction. If crowns are supplied, the function will tile these with the image
637
-
and skip tiles without a minimum coverage of crowns. The 'threshold' can be varied to ensure good coverage of
638
-
crowns across a training tile. Tiles that do not have sufficient coverage are skipped.
652
+
Tiles up large rasters into manageable tiles for training and prediction. If crowns are not
653
+
supplied, the function will tile up the entire landscape for prediction. If crowns are supplied,
654
+
the function will tile these with the image and skip tiles without a minimum coverage of crowns.
655
+
The 'threshold' can be varied to ensure good coverage of crowns across a training tile. Tiles
656
+
that do not have sufficient coverage are skipped.
639
657
640
658
Args:
641
-
img_path: Path to the orthomosaic
642
-
out_dir: Output directory
643
-
buffer: Overlapping buffer of tiles in meters (UTM)
644
-
tile_width: Tile width in meters
645
-
tile_height: Tile height in meters
646
-
crowns: Crown polygons as a GeoPandas DataFrame
647
-
threshold: Minimum proportion of the tile covered by crowns to be accepted [0,1]
648
-
nan_threshold: Maximum proportion of tile covered by NaNs [0,1]
649
-
dtype_bool: Flag to edit dtype to prevent black tiles
650
-
mode: Type of the raster data ("rgb" or "ms")
651
-
class_column: Name of the column in `crowns` DataFrame for class-based tiling
659
+
img_path: Path to the orthomosaic.
660
+
out_dir: Output directory.
661
+
buffer: Overlapping buffer of tiles in meters (UTM).
662
+
tile_width: Tile width in meters.
663
+
tile_height: Tile height in meters.
664
+
crowns: Crown polygons as a GeoDataFrame.
665
+
threshold: Minimum proportion of the tile covered by crowns to be accepted [0,1].
666
+
nan_threshold: Maximum proportion of the tile covered by NaNs [0,1].
667
+
dtype_bool: Flag to edit dtype to prevent black tiles.
668
+
mode: Type of the raster data ("rgb" or "ms").
669
+
class_column: Name of the column in `crowns` DataFrame for class-based tiling.
652
670
tile_placement: Strategy for placing tiles.
653
671
"grid" for fixed grid placement based on the bounds of the input image, optimized for speed.
654
672
"adaptive" for dynamic placement of tiles based on crowns, adjusts based on data features for better coverage.
673
+
mask_path: Path to a mask file to use for tiling.
674
+
multithreaded: Flag to enable multithreaded processing.
675
+
random_subset: Number of random tiles it will try to process per image. If -1, all tiles are processed.
676
+
additional_nodata: List of additional pixel values to treat as nodata.
677
+
overlapping_tiles: Flag to enable overlapping tiles for more training data generation. More useful for training the detection part of the Mask R-CNN model.
0 commit comments