Learn R Programming

modisfast (version 2.0.0)

mf_get_url: Find download URLs for MODIS, VIIRS and GPM data

Description

Find the files covering your area and dates, and create URLs to download only the selected bands and area. Use [mf_download_data()] to download them.

Usage

mf_get_url(
  collection,
  variables = NULL,
  roi,
  time_range,
  collection_id = NULL,
  verbose = "inform"
)

Value

A data frame with the download URLs for [mf_download_data()].

Arguments

collection

Collection identifier, e.g. `"MOD11A1.061"`, `"VNP43MA4.002"` or `"GPM_3IMERGDF.07"`.

variables

One or more band names to retrieve, as returned by [mf_list_variables()].

roi

An `sf` polygon with an `id` column.

time_range

One date or two bounding dates.

collection_id

Optional Earthdata Cloud collection ID. Usually leave this empty; the package finds it in its collection catalogue. Not used for GPM.

verbose

Character string: `"quiet"`, `"inform"` (default), or `"debug"`. Controls progress messages; `"debug"` also shows request details.

Details

Set `EARTHDATA_TOKEN` to your Earthdata token before calling this function.

Examples

Run this code
if (FALSE) {
Sys.setenv(EARTHDATA_TOKEN = "your Earthdata bearer token")
roi <- sf::st_as_sf(data.frame(id = "test", geom =
  "POLYGON ((3.8 43.5, 4 43.5, 4 43.7, 3.8 43.7, 3.8 43.5))"),
  wkt = "geom", crs = 4326)
time_range <- as.Date(c("2026-01-01", "2026-01-30"))
urls_vj121a2 <- mf_get_url("VJ121A2.002",
  c("LST_Day_1KM", "LST_Night_1KM"), roi, time_range)
mf_download_data(urls_vj121a2)
}

Run the code above in your browser using DataLab