hypso.classification.WaterDetection.waterdetect.InputOutput

Module Contents

Classes

DWLoader

DWSaver

DWS2CORMaskProcessor

DWLandsatMaskProcessor

DWTheiaMaskProcessor

class hypso.classification.WaterDetection.waterdetect.InputOutput.DWLoader(input_folder, shape_file=None, product='S2_THEIA', ref_band='Red', single_mode=False)
property product_dict
property area_name

Extracts the name of the area based on the shapefile name :return: name of the area

property current_image_folder

Returns the full path folder of current (selected) image :return: Posixpath of current image

property current_image_name

Returns the name of the current (selected) image :return: String name of the current (selected) image

property bands_path

Return the directory of the bands depending on the product :return: PosixPath of the directory containing the bands

property granule_metadata

Returns the full path folder of the image’s granule metadata :return: Posixpath of current image’s granule metadata

property metadata

Returns the full path folder of the image’s metadata :return: Posixpath of current image’s metadata

property glint_name

” Name of the glint image for the report

property projection
property geo_transform
property x_size
property y_size
satellite_Dict
band_ids
__len__()
__iter__()
__next__()
get_bands_files()

Retrieve the full path of bands saved for the current image, according to the product :return: Posix_path of bands files

open_current_image(ref_band_name='Red')

Load a bands list, given a image_list and a dictionary of Keys(BandName) and identifiers to parse the filename ex. {‘Green’:’B3’, ‘Red’:’B4’…} The result, will be a dictionary with Keys(BandName) and GdalDatasets as values

static open_gdal_image(bands_list, desired_band)

Get the image in the list corresponding to the informed Band. Return the image opened with GDAL as a RasterImage object If cant find the band return None If is more than 1 image, raise exception

clip_bands(bands_to_clip, ref_band, temp_dir)
get_offset(band)

Get the offset value to be applied to the band. This offset exists in the Sen2Cor images after 25 January 2022. https://sentinels.copernicus.eu/documents/247904/4830984/OMPC.CS.DQR.002.07-2022%20-%20i52r0%20-%20MSI%20L2A%20DQR%20August%202022.pdf/36edbb04-0c6c-fba3-5c34-0ba3be82e91c @param band: Reflectance band @return: Value to be added to the loaded band

load_raster_bands(bands_list)
Parameters:

bands_list (list) –

update_mask(mask)
load_masks(product_masks_list, external_mask, mask_name, mask_valid_value=None, mask_invalid_value=None)
class hypso.classification.WaterDetection.waterdetect.InputOutput.DWSaver(output_folder, product_name, area_name=None)
property area_name
property temp_dir
set_output_folder(image_name, geo_transform, projection)

For each image, the saver has to prepare the specific output directory, and saving parameters. The output directory is based on the base_output_folder, the area name and the image name :param image_name: name of the image being processed :param geo_transform: geo transformation to save rasters :param projection: projection to save rasters :return: Nothing

update_geo_transform(geo_transform, projection)
static create_base_name(product_name, image_name)
static create_output_folder(output_folder, image_name, area_name)
save_array(array, name, opt_relative_path=None, no_data_value=0, dtype=None)
save_rgb_array(red, green, blue, name, opt_relative_path=None)
save_multiband(array, name, opt_relative_path=None, no_data_value=0, dtype=None)

Save a multilayer array

Parameters:
  • array – array with all bands wanted

  • name – name of the output

Returns:

the complete filename

class hypso.classification.WaterDetection.waterdetect.InputOutput.DWS2CORMaskProcessor(base_folder, x_size, y_size, shape_file=None, temp_dir=None)
Sen2CorMaskList
open_mask(shape_file, temp_dir)
open_gdal_masks(shape_file, temp_dir)
get_combined_masks(masks_list)
class hypso.classification.WaterDetection.waterdetect.InputOutput.DWLandsatMaskProcessor(base_folder, x_size, y_size, shape_file=None, temp_dir=None)
LandsatMaskDict
open_mask(shape_file, temp_dir)
open_gdal_masks(shape_file, temp_dir)
get_combined_masks(masks_list)
class hypso.classification.WaterDetection.waterdetect.InputOutput.DWTheiaMaskProcessor(base_folder, x_size, y_size, shape_file=None, temp_dir=None)
TheiaMaskDict
TheiaCLMDict
TheiaMG2Dict
open_masks(shape_file, temp_dir)
open_gdal_masks(shape_file, temp_dir)
get_combined_masks(masks_list)