diff --git a/test/drs_import.py b/apps/drs_spot67_import.py similarity index 72% rename from test/drs_import.py rename to apps/drs_spot67_import.py index f6b3912adf87d1306c9e2dc3fd7cc056e4437117..67f4532ba1f88e31db1cbcac42a5579ad3b38e27 100644 --- a/test/drs_import.py +++ b/apps/drs_spot67_import.py @@ -3,8 +3,9 @@ from scenes import save_scenes from scenes.spot import get_spot67_scenes # Arguments -parser = argparse.ArgumentParser(description="Test",) +parser = argparse.ArgumentParser(description="Import Spot-6/7 images from DRS into a list of scenes (pickle)",) parser.add_argument("--root_dirs", nargs='+', help="Root directories containing MS and PAN folders", required=True) +parser.add_argument("--tile_name", help="Filter only images from this tile (optional)") parser.add_argument("--out_pickle", help="Output pickle file", required=True) params = parser.parse_args() diff --git a/apps/s2_import.py b/apps/s2_import.py new file mode 100644 index 0000000000000000000000000000000000000000..a07c89af09553ec849f338c3550421ece8fc4221 --- /dev/null +++ b/apps/s2_import.py @@ -0,0 +1,16 @@ +import argparse +from scenes import save_scenes +from scenes.sentinel import get_local_scenes + +# Arguments +parser = argparse.ArgumentParser(description="Test",) +parser.add_argument("--root_dirs", nargs='+', help="Root directories containing S2 archives (.zip)", required=True) +parser.add_argument("--out_pickle", help="Output pickle file", required=True) +parser.add_argument("--tile_name", help="(Optional) Tile name") +params = parser.parse_args() + +# Search all Sentinel-2 scenes +s2_scenes = [get_local_scenes(root_dir=root_dir, tile=params.tile_name) for root_dir in params.root_dirs] + +# Save scenes in a pickle file +save_scenes(s2_scenes, params.out_pickle) diff --git a/apps/search.py b/apps/search.py new file mode 100644 index 0000000000000000000000000000000000000000..7cc95cec76c015edc66397a0ad03739c729146a3 --- /dev/null +++ b/apps/search.py @@ -0,0 +1,25 @@ +import argparse +from scenes import load_scenes, Index + +# Arguments +parser = argparse.ArgumentParser(description="Search scenes intesecting an ROI",) +parser.add_argument("--pickle_file", help="List of scenes (serialized in pickle format)", required=True) +parser.add_argument("--roi", help="ROI. Can be a vector or a raster", required=True) +params = parser.parse_args() + +# Load scenes list +scenes = load_scenes(params.pickle_file) + +# spatial index +print("Indexation...") +idx = Index(scenes) + +# search +print("Search roi") +bbox_fn = utils.get_bbox_wgs84_from_raster if params.roi.lower().endswith(".tif") \ + else utils.get_bbox_wgs84_from_vector +matches = idx.find(bbox_wgs84=bbox_fn(params.roi)) +print(f"{len(matches)} scenes found.") +for i, scene_match in enumerate(matches): + print(f"Scene #{i}") + print(scene_match) diff --git a/test/drs_search.py b/test/drs_search.py deleted file mode 100644 index eb11015ef2bdab4c4e0b6d807a5afd44b1fecaff..0000000000000000000000000000000000000000 --- a/test/drs_search.py +++ /dev/null @@ -1,24 +0,0 @@ -import argparse -from scenes import utils, Index - -# Arguments -parser = argparse.ArgumentParser(description="Test",) -parser.add_argument("--root_dir", help="Root directory containing MS and PAN folders", required=True) -parser.add_argument("--roi", required=True) -params = parser.parse_args() - -# Find pairs of DIMAPS -scenes = drs.get_spot67_scenes(params.root_dir) - -# spatial index -print("Indexation...") -idx = Index(scenes) - -# search -print("search roi") -bbox_fn = utils.get_bbox_wgs84_from_raster if params.roi.lower().endswith(".tif") \ - else utils.get_bbox_wgs84_from_vector -matches = idx.find(bbox_wgs84=bbox_fn(params.roi)) -print("{} scenes found.".format(len(matches))) -#for scene_match in matches: -# print(scene_match) diff --git a/test/drs_stack.py b/test/drs_stack.py deleted file mode 100644 index 7deaaba3aa2a0beda3497aaaaaf1fa2f90029b7d..0000000000000000000000000000000000000000 --- a/test/drs_stack.py +++ /dev/null @@ -1,34 +0,0 @@ -import argparse -import pyotb -from scenes import utils, Index -from scenes.spot import get_spot67_scenes - -# Arguments -parser = argparse.ArgumentParser(description="Test",) -parser.add_argument("--root_dir", help="Root directory containing MS and PAN folders", required=True) -parser.add_argument("--roi", required=True) -parser.add_argument("--out", required=True) -params = parser.parse_args() - -# Find pairs of DIMAPS -scenes = get_spot67_scenes(params.root_dir) - -# spatial index -print("Indexation...") -idx = Index(scenes) - -# search -print("search roi") -bbox = utils.get_bbox_wgs84_from_raster(params.roi) -matches = idx.find(bbox_wgs84=bbox) -print("{} scenes found.".format(len(matches))) - -# sort -print("sort") -sources_list = [sc.get_imagery().get_xs().resample_over(ref_img=params.roi) for sc in matches] -sources_list.sort(key=lambda src: src.root_imagery.root_scene.acquisition_date) - -# stack -print("concatenation") -concat = pyotb.ConcatenateImages({"il": sources_list}) -concat.write(params.out) diff --git a/test/s2_import.py b/test/s2_import.py deleted file mode 100644 index 98ca99639a180f8ad907389d0e4a37b378467d15..0000000000000000000000000000000000000000 --- a/test/s2_import.py +++ /dev/null @@ -1,19 +0,0 @@ -import argparse -from scenes import utils, sentinel, save_scenes - -# Arguments -parser = argparse.ArgumentParser(description="Test",) -parser.add_argument("--root_dirs", nargs='+', help="Root directories containing S2 archives (.zip)", required=True) -parser.add_argument("--out_pickle", help="Output pickle file", required=True) -parser.add_argument('--level', default='2A', const='2A', nargs='?', choices=['2A', '3A'], help='Product level') -params = parser.parse_args() - -# Get all scenes in the root_dir -product_type = sentinel.Sentinel23AScene if params.level == '2A' else sentinel.Sentinel23AScene -archives = [] -for root_dir in params.root_dirs: - archives += utils.find_files_in_all_subdirs(pth=root_dir, pattern="*.zip", case_sensitive=False) -scenes = [product_type(archive=archive) for archive in archives] - -# Save scenes in a pickle file -save_scenes(scenes, params.out_pickle) diff --git a/test/single_import.py b/test/single_import.py deleted file mode 100644 index d7f43a46c56e6343e6da3156274055da27307a48..0000000000000000000000000000000000000000 --- a/test/single_import.py +++ /dev/null @@ -1,12 +0,0 @@ -import scenes.spot as spot -import argparse - -# Arguments -parser = argparse.ArgumentParser(description="Test",) -parser.add_argument("--dimap_xs", required=True) -parser.add_argument("--dimap_pan", required=True) -params = parser.parse_args() - -# Test spot class -image = spot.Scene(dimap_file_xs=params.dimap_xs, dimap_file_pan=params.dimap_pan) -print(image) \ No newline at end of file