earthdatalogin::edl_netrc()The NASA EarthData program provides access to an extensive collection of spatial data products from each of its 12 Distributed Active Archive Centers (‘DAACs’) on the high-performance S3 storage system of Amazon Web Services (AWS). We can take advantage of range requests with NASA EarthData URLs, but unlike the previous examples, NASA requires an authentication step. NASA offers several different mechanisms, including netrc authentication, token-based authentication, and S3 credentials, but only the first of these works equally well from locations both inside and outside of AWS-based compute, so there really is very little reason to learn the other two.
The earthdatalogin package in R or the earthaccess package in Python handle the authentication. The R package sets up authentication behind the scenes using environmental variables.
(A default login is supplied though users are encouraged to register for their own individual accounts.) Once this is in place, EarthData’s protected URLs can be used like any other:
terra::rast("https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/HLSL30.020/HLS.L30.T56JKT.2023246T235950.v2.0/HLS.L30.T56JKT.2023246T235950.v2.0.SAA.tif",
vsi=TRUE)class : SpatRaster
dimensions : 3660, 3660, 1 (nrow, ncol, nlyr)
resolution : 30, 30 (x, y)
extent : 199980, 309780, 7190200, 7300000 (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / UTM zone 56N (EPSG:32656)
source : HLS.L30.T56JKT.2023246T235950.v2.0.SAA.tif
name : HLS.L30.T56JKT.2023246T235950.v2.0.SAA