utils/dash_utils.py
def download_action(
    polygons: dict,
    selected_polygon_download: str,
    config: CfgNode,
    year: int,
    season: int,
) -> Tuple[List[str], List[float]]:
    """Downloads satellite data using sentinel API.
        Due to API limitation, if a selected polygon is too big,
        it is splited into smaller ones which are downloaded instead.
        Returns paths to downloaded images and corresponding coordinates.

    Args:
        polygons (dict): Dictioneries with coordinates of all polygons
        selected_polygon_download (str): Id of selected polygon for download
        config (CfgNode): App config
        year (int): Year of the satellite data
        season (str): Season of the satellite data

    Returns:
        Tuple[List[str], List[float]]: A Tuple containing
            * List of paths to downloaded image
            * List of corresponding coordinates, in format:
                [[south, west], [north, east]]
    """
    coord = get_polygon_coord(polygons, int(selected_polygon_download))

    all_coords_json = load_json(os.path.join(config.DATA_DIR, config.POLYGON_JSON_NAME))
    polygon_id = get_polygon_id_from_json(all_coords_json, coord)
    if polygon_id >= 0:
        foldername = str(polygon_id)
    else:
        foldername = get_next_folder_name(config.DATA_DIR)
    savedir = os.path.join(config.DATA_DIR, foldername + f"_y{year}_s{season}")

    # Save coords for whole polygon and all tiles
    coords = get_raster_from_coord(coord[0], coord[1], config, savedir, year, season)

    write_json(os.path.join(config.DATA_DIR, config.POLYGON_JSON_NAME), coords)

    img_paths = glob.glob(f"{savedir}/*.npy")
    paths = []
    coords_collected = []

    for img_path in img_paths:
        img = convert_sat_np_for_vis(img_path)
        png_path = img_path.replace(".npy", ".png")
        cv2.imwrite(png_path, img)

        converted_coord = get_converted_coords_from_dict(coords, png_path)

        paths.append(png_path)
        coords_collected.append(converted_coord)

    return paths, coords_collected
Downloads satellite data using sentinel API.
        Due to API limitation, if a selected polygon is too big,
        it is splited into smaller ones which are downloaded instead.
        Returns paths to downloaded images and corresponding coordinates.

    Args:
        polygons (dict): Dictioneries with coordinates of all polygons
        selected_polygon_download (str): Id of selected polygon for download
        config (CfgNode): App config
        year (int): Year of the satellite data
        season (str): Season of the satellite data

    Returns:
        Tuple[List[str], List[float]]: A Tuple containing
            * List of paths to downloaded image
            * List of corresponding coordinates, in format:
                [[south, west], [north, east]]
    
Downloads satellite data using sentinel API.
Due to API limitation, if a selected polygon is too big,
it is splited into smaller ones which are downloaded instead.
Returns paths to downloaded images and corresponding coordinates.
Downloads satellite data using sentinel API . Due to API limitation if a selected polygon is too big it is splited into smaller ones which are downloaded instead . Returns paths to downloaded images and corresponding coordinates .
def download_action(
    polygons: dict,
    selected_polygon_download: str,
    config: CfgNode,
    year: int,
    season: int,
) -> Tuple[List[str], List[float]]:
    coord = get_polygon_coord(polygons, int(selected_polygon_download))
    all_coords_json = load_json(os.path.join(config.DATA_DIR, config.POLYGON_JSON_NAME))
    polygon_id = get_polygon_id_from_json(all_coords_json, coord)
    if polygon_id >= 0:
        foldername = str(polygon_id)
    else:
        foldername = get_next_folder_name(config.DATA_DIR)
    savedir = os.path.join(config.DATA_DIR, foldername + f"_y{year}_s{season}")
    coords = get_raster_from_coord(coord[0], coord[1], config, savedir, year, season)
    write_json(os.path.join(config.DATA_DIR, config.POLYGON_JSON_NAME), coords)
    img_paths = glob.glob(f"{savedir}/*.npy")
    paths = []
    coords_collected = []
    for img_path in img_paths:
        img = convert_sat_np_for_vis(img_path)
        png_path = img_path.replace(".npy", ".png")
        cv2.imwrite(png_path, img)
        converted_coord = get_converted_coords_from_dict(coords, png_path)
        paths.append(png_path)
        coords_collected.append(converted_coord)
    return paths, coords_collected
def download_action ( polygons : dict , selected_polygon_download : str , config : CfgNode , year : int , season : int , ) -> Tuple [ List [ str ] , List [ float ] ] : coord = get_polygon_coord ( polygons , int ( selected_polygon_download ) ) all_coords_json = load_json ( os . path . join ( config . DATA_DIR , config . POLYGON_JSON_NAME ) ) polygon_id = get_polygon_id_from_json ( all_coords_json , coord ) if polygon_id >= 0 : foldername = str ( polygon_id ) else : foldername = get_next_folder_name ( config . DATA_DIR ) savedir = os . path . join ( config . DATA_DIR , foldername + f"_y{year}_s{season}" ) coords = get_raster_from_coord ( coord [ 0 ] , coord [ 1 ] , config , savedir , year , season ) write_json ( os . path . join ( config . DATA_DIR , config . POLYGON_JSON_NAME ) , coords ) img_paths = glob . glob ( f"{savedir}/*.npy" ) paths = [ ] coords_collected = [ ] for img_path in img_paths : img = convert_sat_np_for_vis ( img_path ) png_path = img_path . replace ( ".npy" , ".png" ) cv2 . imwrite ( png_path , img ) converted_coord = get_converted_coords_from_dict ( coords , png_path ) paths . append ( png_path ) coords_collected . append ( converted_coord ) return paths , coords_collected
Downloads satellite data using sentinel API.
Downloads satellite data using sentinel API .
"""Downloads satellite data using sentinel API.
        Due to API limitation, if a selected polygon is too big,
        it is splited into smaller ones which are downloaded instead.
        Returns paths to downloaded images and corresponding coordinates.

    Args:
        polygons (dict): Dictioneries with coordinates of all polygons
        selected_polygon_download (str): Id of selected polygon for download
        config (CfgNode): App config
        year (int): Year of the satellite data
        season (str): Season of the satellite data

    Returns:
        Tuple[List[str], List[float]]: A Tuple containing
            * List of paths to downloaded image
            * List of corresponding coordinates, in format:
                [[south, west], [north, east]]
    """ # Save coords for whole polygon and all tiles
A Tuple containing
List of paths to downloaded image
List of corresponding coordinates, in format:
[[south, west], [north, east]]
A Tuple containing List of paths to downloaded image List of corresponding coordinates in format : [[ south west ] [ north east ]]
Tuple[List[str], List[float]]
polygons
dict
Dictioneries with coordinates of all polygons
Dictioneries with coordinates of all polygons
selected_polygon_download
str
Id of selected polygon for download
Id of selected polygon for download
config
CfgNode
None
year
int
Year of the satellite data
Year of the satellite data
season
int
Season of the satellite data
Season of the satellite data