Hi Is there an convient way to donwload Modis data using an R script? Here an example of teh faile I would liek to download:
http://oceandata.sci.gsfc.nasa.gov [/opendap/MODISA/L3SMI/2017/241/A2017241.L3m_DAY_CHL_chl_ocx_4km.nc]
Thanks for your help.
Val.
Donwload earthdata with R script
-
- Posts: 396
- Joined: Mon Jun 22, 2020 5:24 pm America/New_York
- Has thanked: 8 times
- Been thanked: 8 times
Re: Donwload earthdata with R script
Hi Val,
I don't know R, but we have a convenient python script on our site.
If you'd like help with your R script and you don't mind pasting or attaching the code, maybe the user community can be of assistance.
I don't know R, but we have a convenient python script on our site.
If you'd like help with your R script and you don't mind pasting or attaching the code, maybe the user community can be of assistance.
-
- Posts: 10
- Joined: Fri Jun 04, 2021 4:12 pm America/New_York
Re: Donwload earthdata with R script
Hi vharvey,
The following code will download the file you are interested in.
library(ncdf4)
url <- 'http://oceandata.sci.gsfc.nasa.gov [/opendap/MODISA/L3SMI/2017/241/A2017241.L3m_DAY_CHL_chl_ocx_4km.nc]'
modis <- nc_open(url)
chl_ocx <- ncvar_get(modis, 'chl_ocx')
lonm <- ncvar_get(modis, 'lon')
latm <- ncvar_get(modis, 'lat')
nc_close(modis)
Best,
Brendan
The following code will download the file you are interested in.
library(ncdf4)
url <- 'http://oceandata.sci.gsfc.nasa.gov [/opendap/MODISA/L3SMI/2017/241/A2017241.L3m_DAY_CHL_chl_ocx_4km.nc]'
modis <- nc_open(url)
chl_ocx <- ncvar_get(modis, 'chl_ocx')
lonm <- ncvar_get(modis, 'lon')
latm <- ncvar_get(modis, 'lat')
nc_close(modis)
Best,
Brendan