Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Search, Download, and Stream NISAR GCOV Data with earthaccess

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

  2. Search for GCOV data with earthaccess

  3. (Option 1) Download the data to a specified directory

  4. (Option 2) Stream the data and load with xarray

  5. Summary

  6. Resources and references


1. Prerequisites

PrerequisiteImportanceNotes
The software environment for this cookbook must be installedNecessary
  • Rough Notebook Time Estimate: 3 minutes


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:")
results
Found 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)
Loading...
Loading...
Loading...

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': 16*1024*1024,  # 16 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"
)

ds
CPU times: user 2.11 s, sys: 306 ms, total: 2.42 s
Wall time: 7.61 s
Loading...

5. (Option 3) Stream the data from S3 and load with xarray

%%time

import earthaccess
import xarray as xr

s3_links = results[0].data_links(access='direct')

fsspec_config = {
    'cache_type': 'background',
    'block_size': 16*1024*1024,  # 16 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"
)

ds
CPU times: user 1.22 s, sys: 283 ms, total: 1.5 s
Wall time: 2.8 s
Loading...

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