Commit 92047ddd authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

FIX: S2 THEIA download from EODAG (theia_picker down)

parent a8cc0307
No related merge requests found
Showing with 23 additions and 3 deletions
+23 -3
......@@ -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 ---
......
......@@ -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':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment