netrc access
reblekah opened this issue · comments
I am getting the following error when trying to access the HLS Data through the sits_cube() function:
Error in .source_configure_access.hls_cube(source, collection) :
Missing HLS access configuration. Please see instructions in Chapter 4 of on-line book
I have created multiple .netrc files both in my working directory, and home directory as called by R_user_dir()
All .netrc files are a text file with the machine, login and password calls.
I'm not sure how to direct sits to where the files are, or if those files are accessed from a specific path specifically but I have tried to store it in the places that seem most logical to me.
I've also tried using the earthdatalogin package to create and store the files for me and I'm still running into the same error.
Any suggestions would be appreciated:
Dear @reblekah apologies for the late response. To access NASA HLS, users need to registed at NASA EarthData, and save their login and password in a ~/.netrc plain text file in Unix (or %HOME%_netrc in Windows). The file must contain the following fields:
machine urs.earthdata.nasa.gov
login
password
The ".netrc" file should be placed in your home directory, and not in your working directory. Please let us know if you can access NASA HLS doing so.
@gilbertocamara thanks for this amazing package, really impressive work!
Minor comment on the netrc issues: it seems that sits
requires the .netrc
file use newline characters, as shown in your example. I am not sure why that is the case though -- Note that this requirement is not part of the .netrc
specification, and does not match NASA's own instructions on creating a .netrc file. As such, many users who are already accessing NASA data with netrc files will likely be very surprised to find they don't work.
It may be worth noting that the earthdatalogin package on CRAN provides utilities to create a netrc file (as well as the other authentication methods supported by NASA earthdata, including bearer tokens and S3 authentication). Might be worth noting that by default, earthdatalogin::edl_netrc()
does not write netrc files to the HOME directory, since that is a violation of CRAN policy, but has to use the standard directory provided by tools::R_user_dir()
instead, so users will need to override that default or configure your HLS_NETRC_FILE_PATH
setting. Would it be possible for sits
to read that path from a simple env var or R option
setting?
Dear @cboettig Thanks! We will address this issue and allow alternative ways to configure the netrc
file, including the use of earthdatalogin::edl_netrc
.
Dear @reblekah @cboettig, We have now included support for providing the `.netrc' information to access the HLS cloud service.
We now recommend using the earthdatalogin
package to create a .netrc
file with the earthdatalogin::edl_netrc
function, developed by @cboettig. This function creates a properly configured .netrc
file in the user's home directory and an environment variable GDAL_HTTP_NETRC_FILE
. Please take a look at the example below.
library(earthdatalogin)
earthdatalogin::edl_netrc(
username = "<your user name>",
password = "<your password>"
)
Then, we check the version of GDAL. In version 3.7.0 or later, we test if the environmental variable GDAL_HTTP_NETRC_FILE
is present and use it if available to provide the .netrc
info. For earlier versions of GDAL, we check the.netrc
file in the user's home directory.
For the .netrc
file, we accept the format used in sits
1.5.0, with username and password in different lines, and the one recommended by @cboettig, with all information in a single line. We also accept .netrc
user files with more than one line, in case they are used to access different services.
We expect to have addressed your issue. Please let us know if you think the matter is solved.