The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: Interface to the 'MODIS Land Products Subsets' Web Services
Version: 1.1.5
Description: Programmatic interface to the Oak Ridge National Laboratories 'MODIS Land Products Subsets' web services (https://modis.ornl.gov/data/modis_webservice.html). Allows for easy downloads of 'MODIS' time series directly to your R workspace or your computer.
URL: https://github.com/bluegreen-labs/MODISTools
BugReports: https://github.com/bluegreen-labs/MODISTools/issues
Depends: R (≥ 3.4)
Imports: httr, utils, sf, sp, terra, stats, memoise, jsonlite
License: AGPL-3
LazyData: true
ByteCompile: true
RoxygenNote: 7.2.3
Suggests: knitr, markdown, covr, testthat, ggplot2, dplyr
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2023-09-16 13:33:29 UTC; khufkens
Author: Koen Hufkens ORCID iD [aut, cre], BlueGreen Labs [cph, fnd]
Maintainer: Koen Hufkens <koen.hufkens@gmail.com>
Repository: CRAN
Date/Publication: 2023-09-17 00:10:05 UTC

arcachon_lai

Description

MODIS leaf area index (LAI) around the French town of Arcachon derived from the MODIS MOD15A2H product (band Lai_500m).

Usage

arcachon_lai

Format

A MODISTools tidy data frame


arcachon_lc

Description

MODIS land cover (IGBP) around the French town of Arcachon derived from the MODIS MCD12Q2 product (band LC_Type1).

Usage

arcachon_lc

Format

A MODISTools tidy data frame


Download all available bands

Description

Lists all available bands for a MODIS Land Products Subset product.

Usage

mt_bands(product)

Arguments

product

a valid MODIS product name

Value

A data frame of all available bands for a MODIS Land Products Subsets products

See Also

mt_products mt_sites mt_dates

Examples



# list all available MODIS Land Products Subsets products
bands <- mt_bands(product = "MCD12Q2")
head(bands)




Batch download MODIS Land Products subsets

Description

Lists all available dates for a MODIS Land Products Subset product at a particular location.

Usage

mt_batch_subset(
  df,
  product,
  band,
  start = "2000-01-01",
  end = format(Sys.time(), "%Y-%m-%d"),
  km_lr = 0,
  km_ab = 0,
  out_dir = tempdir(),
  internal = TRUE
)

Arguments

df

a CSV file or data frame holding locations and their sitenames to batch process with column names site_name, lat, lon holding the respective sitenames, latitude and longitude. When providing a CSV make sure that the data are comma separated.

product

a valid MODIS product name

band

band to download

start

start date

end

end date

km_lr

km left-right to sample

km_ab

km above-below to sample

out_dir

location where to store all data

internal

should the data be returned as an internal data structure TRUE or FALSE (default = TRUE)

Value

A data frame combining meta-data and actual data values, data from different sites is concatenated into one large dataframe. Subsets can be created by searching on sitename.

See Also

mt_sites mt_dates mt_bands mt_products mt_subset

Examples


## Not run: 
# create data frame with a site_name, lat and lon column
# holding the respective names of sites and their location
df <- data.frame("site_name" = paste("test",1:2))
df$lat <- 40
df$lon <- -110

print(df)

# test batch download
subsets <- mt_batch_subset(df = df,
                        product = "MOD11A2",
                        band = "LST_Day_1km",
                        internal = TRUE,
                        start = "2004-01-01",
                        end = "2004-03-31")

# the same can be done using a CSV file with
# a data structure similar to the dataframe above

write.table(df, file.path(tempdir(),"my_sites.csv"),
 quote = FALSE,
 row.names = FALSE,
 col.names = TRUE,
 sep = ",")

# test batch download form CSV
subsets <- mt_batch_subset(df = file.path(tempdir(),"my_sites.csv"),
                        product = "MOD11A2",
                        band = "LST_Day_1km",
                        internal = TRUE,
                        start = "2004-01-01",
                        end = "2004-03-31"
                        )

head(subsets)

## End(Not run)

Converts lower-left sinusoidal coordinates to lat-lon sf bounding box

Description

Converts lower-left sinusoidal coordinates to lat-lon sf bounding box

Usage

mt_bbox(xllcorner, yllcorner, cellsize, nrows, ncols, transform = TRUE)

Arguments

xllcorner

lower left x coordinate as provided by mt_subset

yllcorner

lower left y coordinate as provided by mt_subset

cellsize

cell size provided by mt_subset

nrows

cell size provided by mt_subset

ncols

cell size provided by mt_subset

transform

transform the bounding box from sin to lat long coordinates, TRUE or FALSE (default = TRUE)

See Also

sin_to_ll, mt_subset

Examples



# Download some test data
subset <- mt_subset(product = "MOD11A2",
                        lat = 40,
                        lon = -110,
                        band = "LST_Day_1km",
                        start = "2004-01-01",
                        end = "2004-03-31",
                        progress = FALSE)

# convert sinusoidal to lat / lon
lat_lon <- sin_to_ll(subset$xllcorner, subset$yllcorner)

# bind with the original dataframe
subset <- cbind(subset, lat_lon)

# convert to bounding box
bb <- apply(subset, 1, function(x){
  mt_bbox(xllcorner = x['xllcorner'],
          yllcorner = x['yllcorner'],
          cellsize = x['cellsize'],
          nrows = x['nrows'],
          ncols = x['ncols'])
})

head(bb)


Download all available dates

Description

Lists all available dates for a MODIS Land Products Subset product at a particular location.

Usage

mt_dates(product, lat, lon, site_id, network)

Arguments

product

a valid MODIS product name

lat

latitude in decimal degrees

lon

longitude in decimal degrees

site_id

site id (overides lat / lon)

network

the network for which to generate the site list, when not provided the complete list is provided

Value

A data frame of all available dates for a MODIS Land Products Subsets products at the given location.

See Also

mt_products mt_sites mt_bands

Examples



# list all available MODIS Land Products Subsets products
bands <- mt_dates(product = "MOD11A2", lat = 40, lon = -110)
head(bands)


Download all available products

Description

Lists all available MODIS Land Products Subset products.

Usage

mt_products()

Value

A data frame of all available MODIS Land Products Subsets products

See Also

mt_bands mt_sites mt_dates

Examples



# list all available MODIS Land Products Subsets products
products <- mt_products()
head(products)



Download all available fixed sites

Description

Lists all available MODIS Land Products Subset pre-processed sites

Usage

mt_sites(network)

Arguments

network

the network for which to generate the site list, when not provided the complete list is provided

Value

A data frame of all available MODIS Land Products Subsets pre-processed sites

See Also

mt_products mt_bands mt_dates

Examples



# list all available MODIS Land Products Subsets products
sites <- mt_sites()
print(head(sites))



Download MODIS Land Products subsets

Description

Download a MODIS Land Products Subset product for a given point location buffered with a given amount of kilometers left-right, top-bottom for a given location (provided as latitude and longitude values).

Usage

mt_subset(
  product,
  band,
  lat,
  lon,
  start = "2000-01-01",
  end = format(Sys.time(), "%Y-%m-%d"),
  km_lr = 0,
  km_ab = 0,
  site_id,
  network,
  site_name = "sitename",
  out_dir = tempdir(),
  internal = TRUE,
  progress = TRUE
)

Arguments

product

a valid MODIS product name

band

band or bands (as a character vector) to download

lat

latitude in decimal degrees

lon

longitude in decimal degrees

start

start date

end

end date

km_lr

km left-right to sample (rounded to the nearest integer)

km_ab

km above-below to sample (rounded to the nearest integer)

site_id

site id (overides lat / lon)

network

the network for which to generate the site list, when not provided the complete list is provided

site_name

arbitrary site name used in writing data to file (default = sitename)

out_dir

path where to store the data if writing to disk (default = tempdir())

internal

should the data be returned as an internal data structure TRUE or FALSE (default = TRUE)

progress

show download progress

Value

A data frame combining meta-data and actual data values.

See Also

mt_sites mt_dates mt_bands mt_products mt_batch_subset

Examples



# list all available MODIS Land Products Subsets products
# download data
subset <- mt_subset(product = "MOD11A2",
                        lat = 40,
                        lon = -110,
                        band = "LST_Day_1km",
                        start = "2004-01-01",
                        end = "2004-03-31",
                        progress = FALSE)
 head(subset)


Convert tidy MODISTools data to terra SpatRaster

Description

Convert tidy MODISTools data to a terra SpatRaster for easy spatial processing and plotting.

Usage

mt_to_terra(df, reproject = FALSE, method = "bilinear")

Arguments

df

a valid MODISTools data frame with a single band (filter for a particular band using the dplyr filter() function or base subset()

reproject

reproject output to lat / long (default = FALSE)

method

character. Method used for estimating the new cell values of a SpatRaster. One of: near: nearest neighbor. This method is fast, and it can be the preferred method if the cell values represent classes. It is not a good choice for continuous values. This is used by default if the first layer of x is categorical. bilinear: bilinear interpolation. This is the default if the first layer of x is numeric (not categorical). cubic: cubic interpolation. cubicspline: cubic spline interpolation.

Value

A terra SpatRaster populated with the tidy dataframe values

See Also

mt_subset mt_batch_subset

Examples



# list all available MODIS Land Products Subsets products
# download data
LC <- mt_subset(product = "MCD12Q1",
 lat = 48.383662,
 lon = 2.610250,
 band = "LC_Type1",
 start = "2005-01-01",
 end = "2005-12-30",
 km_lr = 2,
 km_ab = 2,
 site_name = "testsite",
 internal = TRUE,
 progress = FALSE)

head(LC)

# convert to raster
LC_r <- mt_to_terra(df = LC)


Convert sinusoidal coordinates to lat / lon

Description

A full description of the sinusoidal projection is provided on the lpdaac page: https://lpdaac.usgs.gov/dataset_discovery/modis and wikipedia: https://en.wikipedia.org/wiki/Sinusoidal_projection

Usage

sin_to_ll(x, y)

Arguments

x

sinusoidal x coordinate (vector)

y

sinusoidal y coordinate (vector)

See Also

mt_bbox

Examples



# Download some test data
subset <- mt_subset(product = "MOD11A2",
                        lat = 40,
                        lon = -110,
                        band = "LST_Day_1km",
                        start = "2004-01-01",
                        end = "2004-03-31",
                        progress = FALSE)

# convert sinusoidal to lat / lon
lat_lon <- sin_to_ll(subset$xllcorner, subset$yllcorner)

# bind with the original dataframe
subset <- cbind(subset, lat_lon)
head(subset)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.