How to use the sentinelsat.SentinelAPI function in sentinelsat

To help you get started, we’ve selected a few sentinelsat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sentinelsat / sentinelsat / tests / test_mod.py View on Github external
def test_format_url_custom_api_url():
    api = SentinelAPI("user", "pw", api_url='https://scihub.copernicus.eu/dhus/')
    url = api._format_url()
    assert url.startswith('https://scihub.copernicus.eu/dhus/search')

    api = SentinelAPI("user", "pw", api_url='https://scihub.copernicus.eu/dhus')
    url = api._format_url()
    assert url.startswith('https://scihub.copernicus.eu/dhus/search')
github sentinelsat / sentinelsat / tests / test_mod.py View on Github external
def test_missing_dependency_dataframe(monkeypatch):
    api = SentinelAPI("mock_user", "mock_password")

    with pytest.raises(ImportError):
        monkeypatch.setitem(sys.modules, "pandas", None)
        api.to_dataframe({"test": "test"})

    with pytest.raises(ImportError):
        monkeypatch.setitem(sys.modules, "geopandas", None)
        api.to_geodataframe({"test": "tst"})
github sentinelsat / sentinelsat / tests / test_mod.py View on Github external
def test_trigger_lta_accepted():
    api = SentinelAPI("mock_user", "mock_password")

    request_url = "https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/$value"

    with requests_mock.mock() as rqst:
        rqst.get(
            request_url,
            text="Mock trigger accepted", status_code=202
        )
        assert api._trigger_offline_retrieval(request_url) == 202
github sentinelsat / sentinelsat / tests / test_opensearch.py View on Github external
def test_format_url_custom_api_url():
    api = SentinelAPI("user", "pw", api_url="https://scihub.copernicus.eu/dhus/")
    url = api._format_url()
    assert url.startswith("https://scihub.copernicus.eu/dhus/search")

    api = SentinelAPI("user", "pw", api_url="https://scihub.copernicus.eu/dhus")
    url = api._format_url()
    assert url.startswith("https://scihub.copernicus.eu/dhus/search")
github sentinelsat / sentinelsat / tests / test_download.py View on Github external
def test_trigger_lta_failed(http_status_code):
    api = SentinelAPI("mock_user", "mock_password")
    request_url = "https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/$value"

    with requests_mock.mock() as rqst:
        rqst.get(request_url, status_code=http_status_code)
        with pytest.raises(SentinelAPILTAError):
            api._trigger_offline_retrieval(request_url)
github bird-house / flyingpigeon / scripts / eo_fetch_sentinel.py View on Github external
from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt


region = {"type": "Polygon", "coordinates": [[[-69.87682044199994, 12.427394924000097], [-70.05809485599988, 12.537176825000088], [-70.04873613199993, 12.632147528000104], [-69.93639075399994, 12.53172435100005], [-69.87682044199994, 12.427394924000097]]]}

api = SentinelAPI('nilshempelmann', '****')
footprint = geojson_to_wkt(region)
products = api.query(footprint,
                     producttype='SLC',
                     orbitdirection='ASCENDING')
api.download_all(products)
github clcr / pyeo / pyeo / queries_and_downloads.py View on Github external
product_uuid
        The product UUID (4dfB4-432df....)
    out_folder
        The folder to save the .SAFE file to
    user
        Scihub username
    passwd
        Scihub password

    Notes
    -----
    If interrupted mid-download, there will be a .incomplete file in the download folder. You might need to remove
    this for further processing.

    """
    api = SentinelAPI(user, passwd)
    log.info("Downloading {} from scihub".format(product_uuid))
    prod = api.download(product_uuid, out_folder)
    if not prod:
        log.error("{} failed to download".format(product_uuid))
    zip_path = os.path.join(out_folder, prod['title'] + ".zip")
    log.info("Unzipping {} to {}".format(zip_path, out_folder))
    zip_ref = zipfile.ZipFile(zip_path, 'r')
    zip_ref.extractall(out_folder)
    zip_ref.close()
    log.info("Removing {}".format(zip_path))
    os.remove(zip_path)
github bird-house / flyingpigeon / flyingpigeon / processes / wps_EO_COPERNICUS_search.py View on Github external
if 'start' in request.inputs:
            start = request.inputs['start'][0].data
            start = dt.combine(start, time(0, 0, 0))
        else:
            start = end - timedelta(days=30)

        if (start > end):
            start = dt.now() - timedelta(days=30)
            end = dt.now()
            LOGGER.exception("periode end befor periode start, period is set to the last 30 days from now")

        username = request.inputs['username'][0].data
        password = request.inputs['password'][0].data
        cloud_cover = request.inputs['cloud_cover'][0].data

        api = SentinelAPI(username, password)

        geom = {
          "type": "Polygon",
          "coordinates": [[[ bbox[0], bbox[1]],
                           [ bbox[2], bbox[1]],
                           [ bbox[2], bbox[3]],
                           [ bbox[0], bbox[3]],
                           [ bbox[0], bbox[1]]]]}

        footprint = geojson_to_wkt(geom)

        response.update_status("start searching tiles acording query", 15)

        products = api.query(footprint,
                             date=(start, end),
                             platformname='Sentinel-2',
github clcr / pyeo / pyeo / queries_and_downloads.py View on Github external
cloud : string (optional)
            The maximum cloud clover (as calculated by Copernicus) to download.

    Returns
    -------
    A dictionary of Sentinel-2 granule products that are touched by your AOI polygon, keyed by product ID.
    Returns both level 1 and level 2 data.

    Notes
    -----
    If you get a 'request too long' error, it is likely that your polygon is too complex. The following functions
    download by granule; there is no need to have a precise polygon at this stage.

    """
    # Originally by Ciaran Robb
    api = SentinelAPI(user, passwd)
    footprint = geojson_to_wkt(read_geojson(geojsonfile))
    log.info("Sending Sentinel-2 query:\nfootprint: {}\nstart_date: {}\nend_date: {}\n cloud_cover: {} ".format(
        footprint, start_date, end_date, cloud))
    products = api.query(footprint,
                         date=(start_date, end_date), platformname="Sentinel-2",
                         cloudcoverpercentage="[0 TO {}]".format(cloud))
    return products