An error occurred while loading the file. Please try again.
-
Cresson Remi authored153d4e68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import argparse
import scenes.indexation as indexation
import gdal
import scenes.utils as utils
import scenes.drs as drs
import pyotb
# 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 = drs.get_spot67_scenes(params.root_dir)
# spatial index
print("Indexation...")
idx = indexation.Index(scenes)
# search
print("search roi")
gdal_ds = gdal.Open(params.roi)
bbox = utils.get_bbox_wgs84(gdal_ds)
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)