read_scihub_login() reads the SciHub login information;
write_scihub_login() saves new username and password;
check_scihub_login() checks their validity;
is_scihub_configured() check if SciHub credentials are configured.
Login information is stored in a file apihub.txt inside the
".sen2r" subfolder of the home directory. These functions allow reading
or writing this file, and editing it from the GUI.
In case file apihub.txt is missing, read_scihub_login() searches inside
the environmental variables SCIHUB_USER and SCIHUB_PASSWORD.
read_scihub_login(apihub_path = NA)is_scihub_configured()
check_scihub_login(username, password, service = "apihub")
check_scihub_connection(service = "apihub")
write_scihub_login(
username,
password,
apihub_path = NA,
check = TRUE,
append = FALSE
)
read_scihub_login() returns a matrix of credentials,
in which username is in the first column, password in the second.
is_scihub_configured() returns TRUE if credentials can be
accessed, FALSE if not.
check_scihub_login() returns TRUE if credentials are valid,
FALSE elsewhere.
check_scihub_connection() returns TRUE if internet connection
is available and SciHub is accessible, FALSE otherwise.
write_scihub_login() returns NULL.
Path of the file in which login information is saved. If NA (default) it is automatically read from the package default location.
SciHub username.
SciHub password.
Character: it can be "dhus" or "apihub" (default).
Logical: if TRUE (default), new credentials are checked
before writing them on apihub_path (if they are invalid, an error
is provided);
if FALSE, they are directly written.
Logical: if TRUE, new credentials are added
to the ones existing within apihub_path;
if FALSE (default), apihub_path is replaced with the new ones.
Luigi Ranghetti, phD (2019) luigi@ranghetti.info
Lorenzo Busetto, phD (2019)
Notice that new/recently updated SciHub credentials are recognised by API Hub with a delay of about one week (see https://scihub.copernicus.eu/twiki/do/view/SciHubWebPortal/APIHubDescription for details).
For this reason, newly created credentials can not immediately be used by sen2r,
and password edits on old credentials are not immediately recognised.
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473"), URL: https://sen2r.ranghetti.info/.
# \donttest{
is_scihub_configured()
# }
if (FALSE) {
check_scihub_connection()
check_scihub_login("username", "password")
write_scihub_login("username", "password")
read_scihub_login()
}
Run the code above in your browser using DataLab