Examples Catalog
Below is a list of examples for prefect-earthdata.
Credentials Module
Authenticates with NASA Earthdata using the credentials.
from prefect_earthdata import EarthdataCredentials
earthdata_credentials_block = EarthdataCredentials(
    earthdata_username = "username",
    earthdata_password = "password"
)
earthdata_auth = earthdata_credentials_block.login()
Tasks Module
Searches and downloads granules through NASA Earthdata.
from prefect import flow
from prefect_earthdata.credentials import EarthdataCredentials
from prefect_earthdata.tasks import search_data, download
@flow
def example_earthdata_download_flow():
    earthdata_credentials = EarthdataCredentials(
        earthdata_userame = "username",
        earthdata_password = "password"
    )
    granules = search_data(
        earthdata_credentials,
        count=1,
        short_name="ATL08",
        bounding_box=(-92.86, 16.26, -91.58, 16.97),
    )
    download_path = "/tmp"
    files = download(
        earthdata_credentials,
        granules=granules,
        local_path=download_path
    )
    return granules, files
example_earthdata_download_flow()
from prefect import flow
from prefect_earthdata.credentials import EarthdataCredentials
from prefect_earthdata.tasks import search_data
@flow
def example_earthdata_search_flow():
    earthdata_credentials = EarthdataCredentials(
        earthdata_userame = "username",
        earthdata_password = "password"
    )
    granules = search_data(
        earthdata_credentials,
        count=1,
        short_name="ATL08",
        bounding_box=(-92.86, 16.26, -91.58, 16.97),
    )
    return granules
example_earthdata_search_flow()