Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions geospatial_tools/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ def _download_from_link(
"""

Args:
target_download: str:
output_name: str: (Default value = None)
output_directory: str | Path: (Default value = DATA_DIR)
target_download:
output_name:
output_directory:

Returns:


"""
file_configs = get_yaml_config("data_file_links")
key = target_download
Expand All @@ -42,8 +41,6 @@ def download_usa_polygon(output_name: str = USA_POLYGON, output_directory: str |
Args:
output_name: What name to give to downloaded file
output_directory: Where to save the downloaded file
output_name: str: (Default value = USA_POLYGON)
output_directory: str | Path: (Default value = DATA_DIR)

Returns:
"""
Expand All @@ -62,8 +59,6 @@ def download_s2_tiling_grid(
Args:
output_name: What name to give to downloaded file
output_directory: Where to save the downloaded file
output_name: str: (Default value = SENTINEL_2_TILLING_GRID)
output_directory: str | Path: (Default value = DATA_DIR)

Returns:
"""
Expand Down
75 changes: 31 additions & 44 deletions geospatial_tools/planetary_computer/sentinel_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def max_cloud_cover(self, max_cloud_cover: int):
"""

Args:
max_cloud_cover: int:
max_cloud_cover: int: Max percentage of cloud cover used for Sentinel 2 product search

Returns:

Expand Down Expand Up @@ -123,12 +123,9 @@ def create_date_ranges(self, start_year: int, end_year: int, start_month: int, e
end_year: End year for ranges
start_month: Starting month for each period
end_month: End month for each period (inclusively)
start_year: int:
end_year: int:
start_month: int:
end_month: int:

Returns:
List of date ranges
"""
self.date_ranges = create_date_range_for_specific_period(
start_year=start_year, end_year=end_year, start_month_range=start_month, end_month_range=end_month
Expand All @@ -144,10 +141,11 @@ def find_best_complete_products(self, max_cloud_cover: int | None = None, max_no
the search has found no results will be stored in `self.error_list`

Args:
max_cloud_cover: int | None: (Default value = None)
max_no_data_value: int: (Default value = 5)
max_cloud_cover: Max percentage of cloud cover allowed used for the search (Default value = None)
max_no_data_value: Max percentage of no-data coverage by individual Sentinel 2 product (Default value = 5)

Returns:
Dictionary of product IDs and their corresponding Sentinel 2 tile names.
"""
cloud_cover = self.max_cloud_cover
if max_cloud_cover:
Expand Down Expand Up @@ -201,11 +199,7 @@ def to_file(self, output_dir: str | pathlib.Path) -> None:
"""

Args:
output_dir: str | pathlib.Path:

Returns:


output_dir: Output directory used to write to file
"""
write_results_to_file(
cloud_cover=self.max_cloud_cover,
Expand All @@ -225,10 +219,10 @@ def sentinel_2_complete_tile_search(
"""

Args:
tile_id: int:
date_ranges: list[str]:
max_cloud_cover: int:
max_no_data_value: int: (Default value = 5)
tile_id:
date_ranges:
max_cloud_cover:
max_no_data_value: (Default value = 5)

Returns:

Expand Down Expand Up @@ -276,11 +270,11 @@ def find_best_product_per_s2_tile(
"""

Args:
date_ranges: list[str]:
max_cloud_cover: int:
s2_tile_grid_list: list:
max_no_data_value: int: (Default value = 5)
num_of_workers: int: (Default value = 4)
date_ranges:
max_cloud_cover:
s2_tile_grid_list:
max_no_data_value: (Default value = 5)
num_of_workers: (Default value = 4)

Returns:

Expand Down Expand Up @@ -322,13 +316,12 @@ def _get_best_product_id_for_each_grid_tile(
"""

Args:
s2_tile_search_results: dict:
feature_s2_tiles: GeoDataFrame:
logger: logging.Logger: (Default value = LOGGER)
s2_tile_search_results:
feature_s2_tiles:
logger: (Default value = LOGGER)

Returns:


String value of product id
"""
search_result_keys = s2_tile_search_results.keys()
all_keys_present = all(item in search_result_keys for item in feature_s2_tiles)
Expand Down Expand Up @@ -364,11 +357,11 @@ def write_best_product_ids_to_dataframe(
"""

Args:
spatial_join_results: GeoDataFrame:
tile_dictionary: dict:
best_product_column: str: (Default value = "best_s2_product_id")
s2_tiles_column: str: (Default value = "s2_tiles")
logger: logging.Logger: (Default value = LOGGER)
spatial_join_results:
tile_dictionary:
best_product_column:
s2_tiles_column:
logger:

Returns:

Expand All @@ -391,12 +384,12 @@ def write_results_to_file(
"""

Args:
cloud_cover: int:
successful_results: dict:
incomplete_results: list | None: (Default value = None)
error_results: list | None: (Default value = None)
output_dir: str | pathlib.Path: (Default value = DATA_DIR)
logger: logging.Logger: (Default value = LOGGER)
cloud_cover:
successful_results:
incomplete_results:
error_results:
output_dir:
logger:

Returns:

Expand Down Expand Up @@ -455,15 +448,9 @@ def download_and_process_sentinel2_asset(
base_directory: The base directory path where the downloaded files will be stored
delete_intermediate_files: Flag to determine if intermediate files should be deleted. Defaults to False
logger: Logger instance
product_id: str:
product_bands: list[str]:
collections: str: (Default value = "sentinel-2-l2a")
target_projection: int | str | None: (Default value = None)
base_directory: str | pathlib.Path: (Default value = DATA_DIR)
delete_intermediate_files: bool: (Default value = False)
logger: logging.Logger: (Default value = LOGGER)

Returns:
Asset instance
"""
base_file_name = f"{base_directory}/{product_id}"
merged_file = f"{base_file_name}_merged.tif"
Expand Down
28 changes: 2 additions & 26 deletions geospatial_tools/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ def reproject_raster(
dataset_path: Path to the dataset to be reprojected.
target_crs: EPSG code in string or int format. Can be given in the following ways: 5070 | "5070" | "EPSG:5070"
target_path: Path and filename for reprojected dataset.
logger:
dataset_path: str | pathlib.Path:
target_crs: str | int:
target_path: str | pathlib.Path:
logger: logging.Logger: (Default value = LOGGER)
logger: Logger instance

Returns:

Expand Down Expand Up @@ -88,12 +84,7 @@ def _clip_process(
id_polygon: Tuple containing an id number and a polygon (row from a Geodataframe).
base_output_filename: Base filename for outputs. If `None`, will be taken from input polygon layer.
output_dir: Directory path where output will be written.
raster_image: pathlib.Path | str:
id_polygon: tuple[int:
GeoDataFrame]:
base_output_filename: str | None:
output_dir: pathlib.Path | str:
logger: logging.Logger: (Default value = LOGGER)
logger: Logger instance

Returns:

Expand Down Expand Up @@ -152,12 +143,6 @@ def clip_raster_with_polygon(
output_dir: Directory path where output will be written.
num_of_workers: The number of processes to use for parallel execution. Defaults to `cpu_count()`.
logger: Logger instance
raster_image: pathlib.Path | str:
polygon_layer: pathlib.Path | str | GeoDataFrame:
base_output_filename: str | None: (Default value = None)
output_dir: str | pathlib.Path: (Default value = DATA_DIR)
num_of_workers: int | None: (Default value = None)
logger: logging.Logger: (Default value = LOGGER)

Returns:

Expand Down Expand Up @@ -220,8 +205,6 @@ def get_total_band_count(raster_file_list: list[pathlib.Path | str], logger: log
Args:
raster_file_list: List of raster files to be processed.
logger: Logger instance
raster_file_list: list[pathlib.Path | str]:
logger: logging.Logger: (Default value = LOGGER)

Returns:

Expand All @@ -243,8 +226,6 @@ def create_merged_raster_bands_metadata(
Args:
raster_file_list:
logger:
raster_file_list: list[pathlib.Path | str]:
logger: logging.Logger: (Default value = LOGGER)

Returns:

Expand Down Expand Up @@ -283,11 +264,6 @@ def merge_raster_bands(
With, merged_band_names, individual band id can be assigned for the final output raster;
["B0", "B1", "B2"].
logger: Logger instance
raster_file_list: list[pathlib.Path | str]:
merged_filename: pathlib.Path | str:
merged_band_names: list[str]: (Default value = None)
merged_metadata: dict: (Default value = None)
logger: logging.Logger: (Default value = LOGGER)

Returns:
"""
Expand Down
Loading