Skip to content
Snippets Groups Projects
Commit 0b2b56da authored by pascal.mouquet_ird.fr's avatar pascal.mouquet_ird.fr
Browse files

new class S2cEodag to interact with eodag library

parent a11db502
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ from .library import Library
from .data_request import DataRequest
from .indices import IndicesCollection
from .download_and_process import DownloadAndProcess
from .download_eodag import S2cEodag
from .time_series import TimeSeries
from .automatization import Automatization
from .utils import (
......@@ -56,6 +57,7 @@ from .multi_processing import (
from .tileset import TileSet
from .jobs import Jobs, Job
__version__ = "0.7.0"
__author__ = (
"Jérémy Commins <jebins@laposte.net> & Impact <pascal.mouquet@ird.fr>"
......
......@@ -22,6 +22,7 @@ SHARED_DATA = dict(
peps_download=ROOT / "sen2chain" / "peps_download3.py",
sen2chain_meta=ROOT / "sen2chain" / "data" / "sen2chain_info.xml",
raw_job_cfg=ROOT / "sen2chain" / "data" / "job_ini.cfg",
eodag_centroids_shp=ROOT / "sen2chain" / "data" / "eodag_workspace_locations_tiles" / "sentinel2_tiling_grid_centroids.shp"
)
......
shapefiles:
- name: s2_tile_centroid
path: /home/operateur/sen2chain/sen2chain/data/sentinel2_tiling_grid_centroids.shp
attr: tile_id
\ No newline at end of file
......@@ -13,7 +13,7 @@ from datetime import datetime
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from collections import defaultdict
from sentinelsat import SentinelAPI
from sentinelhub import AwsProductRequest
# from sentinelhub import AwsProductRequest
from pprint import pprint
# type annotations
......
......@@ -6,7 +6,68 @@ Module for downloading Sentinel-2 images using EODAG
https://www.github.com/CS-SI/EODAG
"""
import logging
import shapefile
import os
from pathlib import Path
from eodag import EODataAccessGateway
from .config import SHARED_DATA, Config
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
ROOT = Path(os.path.realpath(__file__)).parent.parent
class S2cEodag:
def __init__(self, name: str):
self.name = name
eodag_centroids_shp = SHARED_DATA.get("eodag_centroids_shp")
with shapefile.Reader(eodag_centroids_shp) as shp:
shaperecs = shp.shapeRecords()
locations_yaml_content = """
shapefiles:
- name: s2_tile_centroid
path: {}
attr: tile_id
""".format(os.path.abspath(eodag_centroids_shp))
eodag_custom_location_cfg = os.path.abspath(Config()._CONFIG_DIR / "eodag_custom_locations.yml")
with open(eodag_custom_location_cfg, "w") as f_yml:
f_yml.write(locations_yaml_content.strip())
self.dag = EODataAccessGateway(locations_conf_path = eodag_custom_location_cfg)
self.dag.set_preferred_provider("peps")
targeted_tile = [
sr
for sr in shaperecs
if sr.record["tile_id"] == name
][0]
def search(
self,
productType = "S2_MSI_L1C",
start: str = "2015-01-01",
end: str = "9999-01-01",
):
default_search_criteria = dict(
productType = productType,
start = start,
end = end
)
products = self.dag.search_all(
locations=dict(s2_tile_centroid=self.name),
**default_search_criteria
)
logger.info("{} products were found given the above search criteria".format(len(products)))
logger.info(products)
logger.info([p.properties["storageStatus"] for p in products])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment