diff --git a/TimeSeries/s2theia.py b/TimeSeries/s2theia.py index 021620c46a1d33756ee73cef9f129ee8ebc8619b..cc5ade78ff8bde7422da5593906f12d2c603595a 100644 --- a/TimeSeries/s2theia.py +++ b/TimeSeries/s2theia.py @@ -2,6 +2,7 @@ import warnings from osgeo import gdal import otbApplication as otb from theia_picker import TheiaCatalog +from eodag import EODataAccessGateway, setup_logging from Common.otb_numpy_proc import to_otb_pipeline import numpy as np @@ -21,8 +22,8 @@ def fetch(shp, dt, output_fld, credentials): theia = TheiaCatalog(credentials) features = theia.search( - start_date=dt.split('/')[0].replace('-','/'), - end_date=dt.split('/')[1].replace('-','/'), + start_date=dt.split('/')[0], + end_date=dt.split('/')[1], bbox=bbox, level='LEVEL2A' ) @@ -35,6 +36,24 @@ def fetch(shp, dt, output_fld, credentials): return S2TheiaPipeline(output_fld) +def fetch_eodag(shp, dt, output_fld, credentials): + bbox = get_query_bbox(shp) + dag = EODataAccessGateway(user_conf_file_path=credentials) + search_criteria = { + "productType": "S2_MSI_L2A_MAJA", + "start": dt.split('/')[0], + "end": dt.split('/')[1], + "geom": {"lonmin": bbox[0], "latmin": bbox[1], "lonmax": bbox[2], "latmax": bbox[3]} + } + res = dag.search_all(**search_criteria) + ret = dag.download_all(res, outputs_prefix=output_fld, extract=True, delete_archive=True) + for f in ret: + im = glob.glob(f+'/*')[0] + os.rename(im, os.path.join(os.path.dirname(f),os.path.basename(im))) + os.rmdir(f) + return ret + + class S2TheiaTilePipeline: # --- BEGIN SENSOR PROTOTYPE --- diff --git a/Workflows/operations.py b/Workflows/operations.py index 7c82d13aa48c3f3d5afba11566021388e2422c09..4b97e5cd321bfb8f843496ac67160e4200f579c3 100644 --- a/Workflows/operations.py +++ b/Workflows/operations.py @@ -90,7 +90,8 @@ def fetch(imagery, shp, out_fld, dt=None, auth=None): if imagery not in ['cop-dem-glo-30', 'nasadem'] and dt is None: raise ValueError("Please provide date range option.") if imagery == 's2theia': - s2theia.fetch(shp, dt, out_fld,auth) + #temporarily switch to eodag since theia_picker is unusable + s2theia.fetch_eodag(shp, dt, out_fld, auth) elif imagery == 's2planetary': s2planetary.fetch(shp, dt, out_fld) elif imagery == 's1grd':