modisfast
(formerly
opendapr
) is an R package that provides functions to
speed-up the download of time-series
raster data products derived from some MODIS
and VIIRS
observations, as well as other widely-used satellite-derived
environmental data (e.g. Global Precipitation Measurement Mission).
modisfast
uses the abilities offered by
the OPeNDAP framework
(Open-source Project for a Network Data Access Protocol) to
download a subset of Earth science data cube, along spatial, temporal or
any other data dimension (depth, …). This way, it reduces downloading
time and disk usage to their minimum : no more 1° x 1° MODIS tiles with
10 bands when your region of interest is only 30 km x 30 km wide and you
need 2 bands ! Moreover, modisfast
enables parallel
downloads of data.
modisfast
is hence particularly suited for retrieving
MODIS or VIIRS data over long time series and
over areas, rather than short time series and
points.
Below is a comparison of modisfast with other packages available for downloading chunks of remote sensing data :
Package | Data | Temporal subsetting* | Spatial subsetting* | Dimensional subsetting* | Speed |
---|---|---|---|---|---|
modisfast |
MODIS, VIIRS, GPM | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
MODIS |
MODIS | :white_check_mark: | :x: | :x: | :white_check_mark: |
MODIStsp |
MODIS | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: |
MODISTools |
MODIS and VIIRS (but not all collections) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
appeears |
MODIS, VIIRS, and many others | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
* at the downloading phase
The package can be installed with:
if(!require(devtools)){install.packages("devtools")}
::install_github("ptaconet/modisfast")
devtoolslibrary(modisfast)
Accessing and opening MODIS data with modisfast
is a
simple 3-steps workflow, as shown in the example below.
1/ First, define the variables of interest (ROI, time frame, collection, and bands) :
# Load the packages
library(modisfast)
library(sf)
library(terra)
# ROI and time range of interest
<- st_as_sf(data.frame(id = "roi_id", 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) # a ROI of interest, format sf polygon
roi <- as.Date(c("2017-01-01","2017-06-01")) # a time range of interest
time_range
# MODIS collections and variables (bands) of interest
<- "MOD11A2.061" # run mf_list_collections() for an exhaustive list of collections available
collection <- c("LST_Day_1km","LST_Night_1km","QC_Day","QC_Night") # run mf_list_variables("MOD11A2.061") for an exhaustive list of variables available for the collection "MOD11A1.062" variables
2/ Then, get the URL of the data and download them :
## Login to Earthdata servers with your EOSDIS credentials.
# To create an account (free) go to : https://urs.earthdata.nasa.gov/.
<- mf_login(credentials = c("username","password")) # set your own EOSDIS username and password
log
## Get the URLs of the data
<- mf_get_url(
urls collection = collection,
variables = variables,
roi = roi,
time_range = time_range
)
## Download the data. By default the data is downloaded in a temporary directory, but you can specify a folder
<- mf_download_data(urls, parallel = T) res_dl
3/ And finally, open the data in R as a
terra::SpatRaster
object using the function
mf_import_data()
(:warning: see here
why you should use this function, instead of the original
terra::rast()
, in the context of modisfast
)
:
<- mf_import_data(
r path = dirname(res_dl$destfile[1]),
collection = collection,
proj_epsg = 4326
)
::plot(r) terra
et voilà !
Want more examples of use of modisfast
? Have a
look at the vignette("get_started")
to get started with a simple example, and see the vignette("modisfast2")
for a more advanced workflow !
Currently modisfast
supports download of 77 data
collections, extracted from the following meta-collections :
In addition, modisfast
supports download of the
following satellite-derived environmental data :
Details of each product available for download are provided in the
tables above or through the function mf_list_collections()
.
Want more details on a specific collection ? Click on the “DOI” column
!
modisfast
is particularly suited for retrieving MODIS or
VIIRS data over long time series and over
areas, rather than short time series and points.
There are other R packages available for accessing MODIS data, which may be more suitable if your requirements differ. These include :
Next developments may involve including access to more collections from other OPeNDAP servers, and submitting the package to the CRAN and the rOpenSci archives.
Any contribution is welcome !
This package is licensed under a GNU General Public License v3.0 or later license.
We thank in advance people that use modisfast
for citing
it in their work / publication(s). For this, please use the following
citation :
Paul Taconet, Nicolas Moiroux. ‘modisfast’ : fast and efficient access to MODIS data with R. 2024, ⟨swh:1:dir:21b5ddcecb39e683c9f2fc5c135f23dc1b36fe28;origin=https://github.com/ptaconet/modisfast;visit=swh:1:snp:4064f0aae2b29808e9cbd096afaa495fd1360f78;anchor=swh:1:rev:9e5b2a456a0e1acd8ab34e6909424ae6c403150d⟩. ⟨hal-04603903⟩
modisfast
work ?modisfast
is an R wrapper for OPeNDAP (Open-source
Project for a Network Data Access Protocol). When utilized by data
providers, such as those managing many NASA datasets, OPeNDAP allows for
subsetting portions of Earth observation cubes based on any dimension by
specifying filters in a URL. modisfast
facilitates this
process by constructing the URL based on the spatial, temporal, and
dimensional filters provided by the user in the function
mf_get_url()
.
Let’s take an example to understand.
The following URL :arrow_down:
https
provides a link to download the MOD11A2.061 data in netCDF, subsetted for :
The indices within the []
refer to values encoding for
the spatial and temporal filters.
These OPeNDAP URLs are not trivial to build. modisfast
converts the spatial, temporal and dimensional filters (R objects)
provided by the user through the function mf_get_url()
into
the appropriate OPeNDAP URL(s). Subsequently, the function
mf_download_data()
allows for downloading the data using
the httr
and
parallel
packages.
We thank NASA and its partners for making all their Earth science
data freely available, and implementing open data access protocols such
as OPeNDAP. modisfast
heavily builds on top of the OPeNDAP,
so we thank the non-profit OPeNDAP, Inc. for developing
the eponym tool in an open and collaborative way.
We also thank the contributors that have tested the package, reviewed the documentation and brought valuable feedbacks to improve the package : Florian de Boissieu, Julien Taconet, Nicolas Moiroux
The initial development and first release of this package were financed by the MIVEGEC unit of the French Research Institute for Sustainable Development, as part of the REACT project.
By enabling to download subsets of data cubes, modisfast
facilites the access to Earth science data for R users in places where
internet connection is slow or expensive and promotes digital sobriety
for our research work.
The OPeNDAP, over which the package builds, is a project developed by
the non-profit OPeNDAP,
Inc. and advanced openly and collaboratively. By using this data
access protocol, modisfast
support the open-source-software
movement.