def search(aoi, start_date=None, end_date=None, satellite='L8', sensor='OLITIRS', api='devseed'): """ Search Landsat 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 api (str, optional): either gcloud (default), scihub, planet or devseed satellite (str, optional): either L1...L8 sensor (str, optional): MSS, TM, ETM, OLITIRS see https://landsat.usgs.gov/what-are-band-designations-landsat-satellites Returns: list of image objects """ # list available images if api == 'gcloud': from tsd import search_gcloud images = search_gcloud.search(aoi, start_date, end_date, satellite=satellite, sensor=sensor) elif api == 'devseed': from tsd import search_devseed images = search_devseed.search(aoi, start_date, end_date, satellite='Landsat-8') images = [l8_metadata_parser.LandsatImage(img, api) for img in images] # sort images by acquisition day, then by mgrs id images.sort(key=(lambda k: (k.date.date(), k.row, k.path))) print('Found {} images'.format(len(images))) return images
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, satellite='L8', sensor='OLITIRS', api='stac', unique_path_row_per_datatake=True): """ Search Landsat 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 api (str, optional): either stac (default) or gcloud satellite (str, optional): either L4, L5, L7 or L8 sensor (str, optional): MSS, TM, ETM, OLITIRS. See: https://landsat.usgs.gov/what-are-band-designations-landsat-satellites unique_path_row_per_datatake (bool): if True, only one path/row tile per datatake is considered. The selected path/row is the first in alphabetical order. Returns: list of image objects """ # list available images if api == 'gcloud': from tsd import search_gcloud images = search_gcloud.search(aoi, start_date, end_date, satellite=satellite, sensor=sensor) elif api == 'stac': from tsd import search_stac images = search_stac.search(aoi, start_date, end_date, satellite='Landsat-8') else: raise ValueError('The api "{}" is not available for {}.'.format(api, __file__)) # parse the API metadata images = [l8_metadata_parser.LandsatImage(img, api) for img in images] # sort images by acquisition date, then by row/path images.sort(key=(lambda k: (k.date.date(), k.row, k.path))) # remove duplicates (same acquisition date but different path/row) if unique_path_row_per_datatake: seen = set() unique_images = [] for img in images: if img.date.date() not in seen: seen.add(img.date.date()) unique_images.append(img) images = unique_images 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