Download L3SMI data using R

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
ygrund
Posts: 2
Joined: Fri Jan 07, 2022 11:18 am America/New_York
Answers: 0

Download L3SMI data using R

by ygrund » Fri Jan 07, 2022 12:51 pm America/New_York

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

Tags:

gnwiii
Posts: 688
Joined: Fri Jan 29, 2021 5:51 pm America/New_York
Answers: 2

Re: Download L3SMI data using R

by gnwiii » Wed Jan 12, 2022 8:36 pm America/New_York

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".

ygrund
Posts: 2
Joined: Fri Jan 07, 2022 11:18 am America/New_York
Answers: 0

Re: Download L3SMI data using R

by ygrund » Wed Jan 12, 2022 9:17 pm America/New_York

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 28 times

OB.DAAC - amscott
User Services
User Services
Posts: 253
Joined: Mon Jun 22, 2020 5:24 pm America/New_York
Answers: 1
Has thanked: 4 times
Been thanked: 2 times

Re: Download L3SMI data using R

by OB.DAAC - amscott » Thu Jan 13, 2022 9:08 am America/New_York

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?
###
# 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.

Post Reply