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)
144
-
tile_width: Tile width in meters
145
-
tile_height: Tile height in meters
146
-
dtype_bool: Flag to edit dtype to prevent black tiles
147
-
minx: Minimum x coordinate of tile
148
-
miny: Minimum y coordinate of tile
149
-
crs: Coordinate reference system
150
-
tilename: Name of the tile
141
+
img_path: Path to the orthomosaic.
142
+
out_dir: Output directory.
143
+
buffer: Overlapping buffer of tiles in meters (UTM).
144
+
tile_width: Tile width in meters.
145
+
tile_height: Tile height in meters.
146
+
dtype_bool: Flag to edit dtype to prevent black tiles.
147
+
minx: Minimum x coordinate of the tile.
148
+
miny: Minimum y coordinate of the tile.
149
+
crs: Coordinate reference system.
150
+
tilename: Name of the tile.
151
+
crowns: Crown polygons as a GeoDataFrame used to skip tiles if coverage is below `threshold`.
152
+
threshold: Minimum fraction [0,1] of tile coverage by `crowns` required to avoid skipping the tile.
153
+
nan_threshold: Maximum proportion [0,1] of the tile that can be nodata or NaN values before skipping.
154
+
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.
155
+
additional_nodata: List of additional pixel values to treat as nodata.
156
+
image_statistics: A list of dictionaries where each dictionary contains information about the pixel distribution of that band. One list element per band.
buffer: Overlapping buffer of tiles in meters (UTM)
299
-
tile_width: Tile width in meters
300
-
tile_height: Tile height in meters
301
-
dtype_bool: Flag to edit dtype to prevent black tiles
302
-
minx: Minimum x coordinate of tile
303
-
miny: Minimum y coordinate of tile
304
-
crs: Coordinate reference system
305
-
tilename: Name of the tile
302
+
img_path: Path to the orthomosaic.
303
+
out_dir: Output directory.
304
+
buffer: Overlapping buffer of tiles in meters (UTM).
305
+
tile_width: Tile width in meters.
306
+
tile_height: Tile height in meters.
307
+
dtype_bool: Flag to edit dtype to prevent black tiles.
308
+
minx: Minimum x coordinate of the tile.
309
+
miny: Minimum y coordinate of the tile.
310
+
crs: Coordinate reference system.
311
+
tilename: Name of the tile.
312
+
crowns: Crown polygons as a GeoDataFrame used to skip tiles if coverage is below `threshold`.
313
+
threshold: Minimum fraction [0,1] of tile coverage by `crowns` required to avoid skipping the tile.
314
+
nan_threshold: Maximum proportion [0,1] of the tile that can be nodata or NaN values before skipping.
315
+
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.
316
+
additional_nodata: List of additional pixel values to treat as nodata.
317
+
image_statistics: A list of dictionaries where each dictionary contains information about the pixel distribution of that band. One list element per band.
306
318
307
319
Returns:
308
320
None
@@ -457,19 +469,24 @@ def process_tile_train(
457
469
"""Process a single tile for training data.
458
470
459
471
Args:
460
-
img_path: Path to the orthomosaic
461
-
out_dir: Output directory
462
-
buffer: Overlapping buffer of tiles in meters (UTM)
463
-
tile_width: Tile width in meters
464
-
tile_height: Tile height in meters
465
-
dtype_bool: Flag to edit dtype to prevent black tiles
466
-
minx: Minimum x coordinate of tile
467
-
miny: Minimum y coordinate of tile
468
-
crs: Coordinate reference system
469
-
tilename: Name of the tile
470
-
crowns: Crown polygons as a geopandas dataframe
471
-
threshold: Min proportion of the tile covered by crowns to be accepted {0,1}
472
-
nan_theshold: Max proportion of tile covered by nans
472
+
img_path: Path to the orthomosaic.
473
+
out_dir: Output directory.
474
+
buffer: Overlapping buffer of tiles in meters (UTM).
475
+
tile_width: Tile width in meters.
476
+
tile_height: Tile height in meters.
477
+
dtype_bool: Flag to edit dtype to prevent black tiles.
478
+
minx: Minimum x coordinate of tile.
479
+
miny: Minimum y coordinate of tile.
480
+
crs: Coordinate reference system.
481
+
tilename: Name of the tile.
482
+
crowns: Crown polygons as a geopandas DataFrame.
483
+
threshold: Min proportion of the tile covered by crowns to be accepted {0,1}.
484
+
nan_threshold: Max proportion of tile covered by NaNs.
485
+
mode: Type of the raster data ("rgb" or "ms").
486
+
class_column: Name of the column in `crowns` DataFrame for class-based tiling.
487
+
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.
488
+
additional_nodata: List of additional pixel values to treat as nodata.
489
+
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.
627
644
628
-
Parameters:
629
-
- file_path: str, path to the raster file.
630
-
- values_to_ignore: list, values to ignore in statistics (e.g., NaN, custom values).
631
-
- window_size: int, size of square window for sampling.
632
-
- min_windows: int, minimum number of valid windows to include in statistics.
645
+
Args:
646
+
file_path: str, path to the raster file.
647
+
values_to_ignore: list, values to ignore in statistics (e.g., NaN, custom values).
648
+
window_size: int, size of square window for sampling.
649
+
min_windows: int, minimum number of valid windows to include in statistics.
650
+
mode: str, type of the raster data ("rgb" or "ms").
633
651
634
652
Returns:
635
-
- List of dictionaries containing statistics for each band.
653
+
List of dictionaries containing statistics for each band.
636
654
"""
637
655
ifvalues_to_ignoreisNone:
638
656
values_to_ignore= []
@@ -769,26 +787,32 @@ def tile_data(
769
787
) ->None:
770
788
"""Tiles up orthomosaic and corresponding crowns (if supplied) into training/prediction tiles.
771
789
772
-
Tiles up large rasters into manageable tiles for training and prediction. If crowns are not supplied, the function
773
-
will tile up the entire landscape for prediction. If crowns are supplied, the function will tile these with the image
774
-
and skip tiles without a minimum coverage of crowns. The 'threshold' can be varied to ensure good coverage of
775
-
crowns across a training tile. Tiles that do not have sufficient coverage are skipped.
790
+
Tiles up large rasters into manageable tiles for training and prediction. If crowns are not
791
+
supplied, the function will tile up the entire landscape for prediction. If crowns are supplied,
792
+
the function will tile these with the image and skip tiles without a minimum coverage of crowns.
793
+
The 'threshold' can be varied to ensure good coverage of crowns across a training tile. Tiles
794
+
that do not have sufficient coverage are skipped.
776
795
777
796
Args:
778
-
img_path: Path to the orthomosaic
779
-
out_dir: Output directory
780
-
buffer: Overlapping buffer of tiles in meters (UTM)
781
-
tile_width: Tile width in meters
782
-
tile_height: Tile height in meters
783
-
crowns: Crown polygons as a GeoPandas DataFrame
784
-
threshold: Minimum proportion of the tile covered by crowns to be accepted [0,1]
785
-
nan_threshold: Maximum proportion of tile covered by NaNs [0,1]
786
-
dtype_bool: Flag to edit dtype to prevent black tiles
787
-
mode: Type of the raster data ("rgb" or "ms")
788
-
class_column: Name of the column in `crowns` DataFrame for class-based tiling
797
+
img_path: Path to the orthomosaic.
798
+
out_dir: Output directory.
799
+
buffer: Overlapping buffer of tiles in meters (UTM).
800
+
tile_width: Tile width in meters.
801
+
tile_height: Tile height in meters.
802
+
crowns: Crown polygons as a GeoDataFrame.
803
+
threshold: Minimum proportion of the tile covered by crowns to be accepted [0,1].
804
+
nan_threshold: Maximum proportion of the tile covered by NaNs [0,1].
805
+
dtype_bool: Flag to edit dtype to prevent black tiles.
806
+
mode: Type of the raster data ("rgb" or "ms").
807
+
class_column: Name of the column in `crowns` DataFrame for class-based tiling.
789
808
tile_placement: Strategy for placing tiles.
790
809
"grid" for fixed grid placement based on the bounds of the input image, optimized for speed.
791
810
"adaptive" for dynamic placement of tiles based on crowns, adjusts based on data features for better coverage.
811
+
mask_path: Path to a mask file to use for tiling.
812
+
multithreaded: Flag to enable multithreaded processing.
813
+
random_subset: Number of random tiles it will try to process per image. If -1, all tiles are processed.
814
+
additional_nodata: List of additional pixel values to treat as nodata.
815
+
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