if (FALSE) {
### First login to EOSDIS Earthdata with username and password.
# To create an account go to : https://urs.earthdata.nasa.gov/.
username <- "earthdata_un"
password <- "earthdata_pw"
log <- mf_login(credentials = c(username,password))
### Get the URLs to download the following datasets :
# MODIS Terra LST Daily (MOD11A1.061) (collection)
# Day + Night bands (LST_Day_1km,LST_Night_1km) (variables)
# over a 50km x 70km region of interest (roi)
# for the time frame 2017-01-01 to 2017-01-30 (30 days) (time_range)
roi <- sf::st_as_sf(data.frame(
id = "roi_test",
geom="POLYGON ((-5.82 9.54, -5.42 9.55, -5.41 8.84, -5.81 8.84, -5.82 9.54))"),
wkt="geom",crs = 4326)
time_range = as.Date(c("2017-01-01","2017-01-30"))
(urls_mod11a1 <- mf_get_url(
collection = "MOD11A1.061",
variables = c("LST_Day_1km","LST_Night_1km"),
roi = roi,
time_range = time_range
))
## Download the data :
res_dl <- mf_download_data(urls_mod11a1)
## Import as terra::SpatRast
modis_ts <- mf_import_data(dirname(res_dl$destfile[1]), collection = "MOD11A1.061")
## Plot the data
terra::plot(modis_ts)
}
Run the code above in your browser using DataLab