Hi there,
I would like to modify the R script of "DAAC_Data_Download_R" (https://git.earthdata.nasa.gov/projects/LPDUR/repos/daac_data_download_r/browse/DAACDataDownload.R) to download L3SMI data located at https://oceandata.sci.gsfc.nasa.gov (directaccess/CYAN/L3SMI/). With my Earthdata account credentials, I had no problem to download the .hdf file with the example link in the script, but I couldn't download the .tif files by simply replacing the the link in the script as following,
files <- "https://oceandata.sci.gsfc.nasa.gov (/directaccess/CYAN/L3SMI/2020/366/L2020366.L3m_DAY_CYAN_CI_cyano_CYAN_CONUS_300m_1_1.tif)"
The error message is
"
Downloading: 460 B [1] "L2020366.L3m_DAY_CYAN_CI_cyano_CYAN_CONUS_300m_1_1.tif not downloaded. Verify that your username and password are correct in C:\\Users\\ygrund/.netrc"
"
I am not sure if the error was truly caused by the credentials. It would be very helpful if you could provide me any suggestions.
Thank you,
Yuan Grund
Download L3SMI data using R
Re: Download L3SMI data using R
The R script "works for me" using <<files <- "https://oceandata.sci.gsfc.nasa.gov (/cgi/getfile/L2020366.L3m_DAY_CYAN_CI_cyano_CYAN_CONUS_300m_1_1.tif)">>. You can generate a list of URL's using the file search page: [url]https://oceandata.sci.gsfc.nasa.gov (/api/file_search/)[/url]. In the past, I found I sometimes needed two entries in my .netrc file, one for "machine urs.earthdata.nasa.gov" and one for "machine oceandata.sci.gsfc.nasa.gov".
Re: Download L3SMI data using R
Thanks, ggwii. No I didn't have the luck to get the file downloaded after I wrote both lines "machine urs.earthdata.nasa.gov" and "machine oceandata.sci.gsfc.nasa.gov" to netrc_conn. I attached the R script in this request. Appreciate if you could take a look if there is anything I missed. Thanks!
- Attachments
-
- script.pdf
- (48.99 KiB) Downloaded 38 times
-
- User Services
- Posts: 297
- Joined: Mon Jun 22, 2020 5:24 pm America/New_York
- Has thanked: 7 times
- Been thanked: 2 times
Re: Download L3SMI data using R
I see a message from the Earthdata helpdesk at the bottom of your script that points to potential issues you should investigate and try to correct. Have you addressed them already?
From that message, you can see that your .netrc file is not where it should be. Your 'home' directory is directly under your user. This path appears to be "C:/Users/ygrund/". Please work through the notes shared by the helpdesk above and try your download again.
###
# Issue: ---
# Author: Catalino Cuadrado (catalino.cuadrado@nasa.gov) # Date: 12-19-2018
################################################################################# # Set up R
# You may need to install the httr package.
# install.packages("httr") setwd("C:/Users/ygrund/ygrund_C_Users/PROJECTS/HABs/Branches/2022/ HAB_Shiny_app")
library(httr)
netrc_path <- "./Earthdata/.netrc"
cookie_path <- "./Earthdata/.urs_cookies"
downloaded_file_path <- "./Earthdata/2020/ L2020301.L3m_DAY_CYAN_CI_cyano_CYAN_CONUS_300m_1_1.tif"
# Before using the script
#Set up your ~/.netrc file as listed here: https://wiki.earthdata.nasa.gov/ display/EL/How+To+Access+Data+With+cURL+And+Wget set_config(config(followlocation=1,netrc=1,netrc_file=netrc_path,cookie=cookie_path,cookie httr::GET(url = "https://oceandata.sci.gsfc.nasa.gov (/directaccess/CYAN/L3SMI/ 2020/301/L2020301.L3m_DAY_CYAN_CI_cyano_CYAN_CONUS_300m_1_1.tif)",
write_disk(downloaded_file_path, overwrite = TRUE))
From that message, you can see that your .netrc file is not where it should be. Your 'home' directory is directly under your user. This path appears to be "C:/Users/ygrund/". Please work through the notes shared by the helpdesk above and try your download again.