How do I access data stored in Earthdata Cloud in Python?

Direct Access

When you have found the data you want to use, you have two options. You can download the data to work locally, or access the data directly to work in the cloud. This second way of working is called “Direct Cloud Access” or simply, “Direct Access”. Your compute instance needs to be in Amazon Web Services (AWS) Region us-west-2 in order for the code to run successfully. We authenticate using a netrc file and an Earthdata Login, see the appendix for more information on Earthdata Login and netrc setup.


We can use the earthaccess python library to grab the file URLs and then access them with the xarray library.

#Import packages
import earthaccess
import xarray as xr
#Authentication with Earthdata Login
auth = earthaccess.login(strategy="netrc")
#Access land ice height from ATLAS/ICESat-2 V005 (10.5067/ATLAS/ATL06.005), searching for data over western Greenland coast over two weeks in July 2022. The data are provided as HDF5 granules (files) that span about 1/14th of an orbit.

results = earthaccess.search_data(short_name="ATL06",
                                  temporal = ("2022-07-17","2022-07-31"),
                                  bounding_box = (-51.96423,68.10554,-48.71969,70.70529))
Granules found: 5
#Use xarray to load the data as a multifile dataset for a single group in the HDF5 file, in this case land ice segments:
ds = xr.open_mfdataset(, group='/gt1l/land_ice_segments')
 Opening 5 granules, approx size: 0.0 GB
Dimensions:                (delta_time: 241711)
  * delta_time             (delta_time) datetime64[ns] 2022-07-18T01:00:46.67...
    latitude               (delta_time) float64 dask.array<chunksize=(78325,), meta=np.ndarray>
    longitude              (delta_time) float64 dask.array<chunksize=(78325,), meta=np.ndarray>
Data variables:
    atl06_quality_summary  (delta_time) int8 dask.array<chunksize=(78325,), meta=np.ndarray>
    h_li                   (delta_time) float32 dask.array<chunksize=(78325,), meta=np.ndarray>
    h_li_sigma             (delta_time) float32 dask.array<chunksize=(78325,), meta=np.ndarray>
    segment_id             (delta_time) float64 dask.array<chunksize=(78325,), meta=np.ndarray>
    sigma_geo_h            (delta_time) float32 dask.array<chunksize=(78325,), meta=np.ndarray>
    Description:  The land_ice_height group contains the primary set of deriv...
    data_rate:    Data within this group are sparse.  Data values are provide...

End User License Agreement (EULA)

Sometimes, accessing data in NASA Earthdata Cloud requires an End-User License Agreement (EULA). If you cannot access a dataset, this may be your issue! See these instructions for how to authorize EULAs.

Alternative Access Method without earthaccess

An alternative approach to accessing data is outlined in some notebooks in the Earthdata Cloud Cookbook Appendix! The earthaccess package uses these methods for it’s back end. See this GitHub folder.