Created
November 13, 2025 20:21
-
-
Save chuckwondo/1cdef96c19a8fe9465664d0cdbd15922 to your computer and use it in GitHub Desktop.
Using Python `earthaccess` package from R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #------------------------------------------------------------------------------- | |
| # This assumes the following: | |
| # | |
| # 1. You have an Earthdata Login (EDL) account (https://urs.earthdata.nasa.gov/) | |
| # 2. You have supplied your EDL credentials in either a .netrc file or | |
| # via the environment variables EARTHDATA_USERNAME and EARTHDATA_PASSWORD or | |
| # an EDL token via the environment variable EARTHDATA_TOKEN. | |
| # 3. You have a Python virtual environment or conda environment with earthaccess | |
| # installed. | |
| #------------------------------------------------------------------------------- | |
| install-packages("reticulate") | |
| library(reticulate) | |
| # Uncomment one of the following and change the argument to refer to an | |
| # environment with earthaccess installed. | |
| #use_virtualenv("/path/to/some/virtualenv") | |
| #use_condaenv("some_condaenv") | |
| ea <- import("earthaccess") | |
| ea$login() | |
| results = ea$search_data( | |
| short_name='ATL06', | |
| version='007', | |
| temporal=tuple('2020-03-01', '2020-03-02'), | |
| bounding_box=tuple(-140, 50, -130, 60), | |
| ) | |
| # Download the first 2 results | |
| ea$download(results[c(1, 2)], local_path="~/downloads") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment