def get_time_series(aoi, start_date=None, end_date=None, out_dir='', product_type='GRD', operational_mode='IW', relative_orbit_number=None, swath_identifier=None, search_api='copernicus', download_mirror='peps'): """ Main function: download a Sentinel-1 image time serie. """ # list available images images = search_scihub.search(aoi, start_date, end_date, product_type=product_type, operational_mode=operational_mode, swath_identifier=swath_identifier, relative_orbit_number=relative_orbit_number, api=search_api) # download for image in images: download_sentinel_image(image, out_dir, download_mirror)
def search(aoi, start_date=None, end_date=None, product_type=None, api='devseed'): """ Search Sentinel-2 images covering an AOI and timespan using a given API. Args: aoi (geojson.Polygon): area of interest start_date (datetime.datetime): start of the search time range end_date (datetime.datetime): end of the search time range product_type (str, optional): either 'L1C' or 'L2A' api (str, optional): either devseed (default), scihub, planet or gcloud Returns: list of image objects """ # list available images if api == 'devseed': from tsd import search_devseed images = search_devseed.search(aoi, start_date, end_date, 'Sentinel-2') elif api == 'scihub': from tsd import search_scihub if product_type is not None: product_type = 'S2MSI{}'.format(product_type[1:]) images = search_scihub.search(aoi, start_date, end_date, satellite='Sentinel-2', product_type=product_type) elif api == 'planet': from tsd import search_planet images = search_planet.search(aoi, start_date, end_date, item_types=['Sentinel2L1C']) elif api == 'gcloud': from tsd import search_gcloud images = search_gcloud.search(aoi, start_date, end_date) # parse the API metadata images = [s2_metadata_parser.Sentinel2Image(img, api) for img in images] # sort images by acquisition day, then by mgrs id images.sort(key=(lambda k: (k.date.date(), k.mgrs_id))) # remove duplicates (same acquisition date but different mgrs tile id) seen = set() unique_images = [] for img in images: if img.date not in seen: seen.add(img.date) unique_images.append(img) print('Found {} images'.format(len(unique_images))) return unique_images
def search(aoi, start_date=None, end_date=None, product_type="GRD", operational_mode="IW", swath_identifier=None, relative_orbit_number=None, api='scihub'): """ Search Sentinel-1 images covering an AOI and timespan using a given API. Args: aoi (geojson.Polygon): area of interest start_date (datetime.datetime): start of the search time range end_date (datetime.datetime): end of the search time range product_type (str, optional): either 'GRD' or 'SLC' api (str, optional): either scihub (default) or planet Returns: list of image objects """ # list available images #if api in ['copernicus', 'austria', 'finland']: if api == "scihub": from tsd import search_scihub images = search_scihub.search( aoi, start_date, end_date, satellite='Sentinel-1', product_type=product_type, operational_mode=operational_mode, swath_identifier=swath_identifier, relative_orbit_number=relative_orbit_number, api="copernicus") elif api == 'planet': from tsd import search_planet images = search_planet.search(aoi, start_date, end_date, item_types=['Sentinel1L1C']) # parse the API metadata images = [s1_metadata_parser.Sentinel1Image(img, api) for img in images] # sort images by acquisition day, then by mgrs id images.sort(key=(lambda k: k.date.date())) print('Found {} images'.format(len(images))) return images
def search(aoi=None, start_date=None, end_date=None, product_type="L2A", tile_id=None, title=None, relative_orbit_number=None, api='stac', search_type='contains', unique_mgrs_tile_per_orbit=True): """ Search Sentinel-2 images covering an AOI and timespan using a given API. Args: aoi (geojson.Polygon): area of interest start_date (datetime.datetime): start of the search time range end_date (datetime.datetime): end of the search time range tile_id (str): MGRS tile identifier, e.g. "31TCJ" title (str): product title, e.g. "S2A_MSIL1C_20160105T143732_N0201_R096_T19KGT_20160105T143758" relative_orbit_number (int): relative orbit number, from 1 to 143 product_type (str, optional): either "L1C" or "L2A" (default). Ignored with planet and gcloud APIs. api (str, optional): either stac (default), scihub, planet or gcloud search_type (str): either "contains" or "intersects" unique_mgrs_tile_per_orbit (bool): if True, only one MGRS tile per orbit is considered. The selected MGRS tile is the first in alphabetical order. This is useful to remove duplicates when the input AOI intersects several MGRS tiles. Returns: list of image objects """ # list available images if api == 'scihub': from tsd import search_scihub if product_type is not None: product_type = 'S2MSI{}'.format(product_type[1:]) images = search_scihub.search( aoi, start_date, end_date, satellite="Sentinel-2", product_type=product_type, relative_orbit_number=relative_orbit_number, tile_id=tile_id, title=title, search_type=search_type) elif api == 'stac': from tsd import search_stac images = search_stac.search(aoi, start_date, end_date, satellite="Sentinel-2", product_type=product_type) elif api == 'planet': from tsd import search_planet images = search_planet.search(aoi, start_date, end_date, item_types=['Sentinel2L1C']) elif api == 'gcloud': from tsd import search_gcloud images = search_gcloud.search(aoi, start_date, end_date) # parse the API metadata images = [s2_metadata_parser.Sentinel2Image(img, api) for img in images] # sort images by date, relative_orbit, mgrs_id images.sort(key=(lambda k: (k.date.date(), k.relative_orbit, k.mgrs_id))) # remove duplicates (same pair (date, relative_orbit) but different mgrs_id) if unique_mgrs_tile_per_orbit: seen = set() unique_images = [] for img in images: if (img.date.date(), img.relative_orbit) not in seen: seen.add((img.date.date(), img.relative_orbit)) unique_images.append(img) images = unique_images print('Found {} images'.format(len(images))) return images
def search(aoi, start_date=None, end_date=None, product_type=None, api='devseed', search_type='contains', unique_mgrs_tile_per_datatake=True): """ Search Sentinel-2 images covering an AOI and timespan using a given API. Args: aoi (geojson.Polygon): area of interest start_date (datetime.datetime): start of the search time range end_date (datetime.datetime): end of the search time range product_type (str, optional): either 'L1C' or 'L2A' api (str, optional): either devseed (default), scihub, planet or gcloud search_type (str): either "contains" or "intersects" unique_mgrs_tile_per_datatake (bool): if True, only one MGRS tile per datatake is considered. The selected MGRS tile is the first in alphabetical order. Returns: list of image objects """ # list available images if api == 'devseed': from tsd import search_devseed images = search_devseed.search(aoi, start_date, end_date, 'Sentinel-2') elif api == 'scihub': from tsd import search_scihub if product_type is not None: product_type = 'S2MSI{}'.format(product_type[1:]) images = search_scihub.search(aoi, start_date, end_date, satellite='Sentinel-2', product_type=product_type, search_type=search_type) elif api == 'planet': from tsd import search_planet images = search_planet.search(aoi, start_date, end_date, item_types=['Sentinel2L1C']) elif api == 'gcloud': from tsd import search_gcloud images = search_gcloud.search(aoi, start_date, end_date) # parse the API metadata images = [s2_metadata_parser.Sentinel2Image(img, api) for img in images] # remove images that have no datatake_id images = [img for img in images if hasattr(img, "datatake_id")] # sort images by datatake_id, then by mgrs id images.sort(key=(lambda k: (k.datatake_id, k.mgrs_id))) # remove duplicates (same datatake_id but different mgrs tile id) if unique_mgrs_tile_per_datatake: seen = set() unique_images = [] for img in images: if img.datatake_id not in seen: seen.add(img.datatake_id) unique_images.append(img) images = unique_images print('Found {} images'.format(len(images))) return images
import datetime from tsd import search_scihub from tsd import utils aoi = utils.geojson_geometry_object(29.9793, 31.1346, 5000, 5000) results = search_scihub.search(aoi, start_date=datetime.datetime(2019, 1, 1), end_date=datetime.datetime(2019, 1, 15), satellite='Sentinel-2') expected_titles = [ 'S2A_MSIL1C_20190114T083311_N0207_R021_T36RUU_20190114T085705', 'S2B_MSIL1C_20190109T083329_N0207_R021_T36RUU_20190109T103019', 'S2A_MSIL1C_20190104T083331_N0207_R021_T36RUU_20190104T104619' ] assert ([r['title'] for r in results] == expected_titles)