earthaccess is an open source Python library to search, download, and stream NASA EO data. his notebook demonstrates how to search and download NISAR GCOV data with earthaccess
Overview¶
1. Prerequisites¶
| Prerequisite | Importance | Notes |
|---|---|---|
| The software environment for this cookbook must be installed | Necessary |
Rough Notebook Time Estimate: 3 minutes
2. Search for GCOV data with earthaccess¶
import earthaccess
earthaccess.login()
results = earthaccess.search_data(
short_name='NISAR_L2_GCOV_BETA_V1',
bounding_box=(-10, 20, 10, 50),
temporal=("2025-11", "2025-12"),
# count=10 # (optional) limit the number of results
)
print(f"Found {len(results)} GCOV products:")
resultsFound 69 GCOV products:
3. (Option 1) Download the data to a specified directory¶
from pathlib import Path
data_dir = Path.home() / "GCOV_data_earthaccess_example"
files = earthaccess.download(results[0], data_dir)4. (Option 2) Stream the data over HTTPS¶
%%time
import earthaccess
import xarray as xr
https_links = results[0].data_links(access='external')
fsspec_config = {
'cache_type': 'background',
'block_size': 8 * 1024 * 1024, # 8 MB
}
fs = earthaccess.get_fsspec_https_session()
ds = xr.open_datatree(
fs.open(https_links[0], **fsspec_config),
engine='h5netcdf',
decode_timedelta=False,
phony_dims="access"
)
dsCPU times: user 1.79 s, sys: 286 ms, total: 2.07 s
Wall time: 7.99 s
5. (Option 3) Stream the data from S3 and load with xarray¶
Notes on Chunking¶
This notebook utilizes chunking to break large arrays into smaller blocks. Chunking allows users to inspect and process subsets of a dataset without loading entire arrays into memory at once. In this example, data are accessed using an 8 MB block size for cloud access.
For additional benchmarking and recommendations for NISAR direct-access workflows, see Henry Rodman’s Reading NISAR granules directly from S3.
%%time
import earthaccess
import xarray as xr
s3_links = results[0].data_links(access='direct')
fsspec_config = {
'cache_type': 'background',
'block_size': 8*1024*1024, # 8 MB
}
# The endpoint must be set to the NISAR-specific endpoint
endpoint = 'https://nisar.asf.earthdatacloud.nasa.gov/s3credentials'
fs = earthaccess.get_s3_filesystem(endpoint=endpoint)
ds = xr.open_datatree(
fs.open(s3_links[0], **fsspec_config),
engine='h5netcdf',
decode_timedelta=False,
phony_dims="access"
)
dsCPU times: user 1.02 s, sys: 191 ms, total: 1.21 s
Wall time: 2.6 s
5. Summary¶
You now have the tools and knowledge that you need to search, download, and stream data using the earthaccess Python package.
6. Resources and references¶
Author: Alex Lewandowski
Streaming examples copied directly from the NISAR Data User Guide