modis_tiles: modis_tiles

Description Usage Arguments Details Value

Description

Find the MODIS tiles that cover the area of interest

Usage

1
modis_tiles(sfObject)

Arguments

sfObject

A sf object with either 'POLYGON' or 'MULTIPOLYGON' geometries.

Details

#' modis_data_retrieval #' @param startDate #' @param endDate #' @param sfObject A sf object with either 'POLYGON' or 'MULTIPOLYGON' geometries. #' @param param Should be of 'D_CWU' #' @param dataFolder Path #' @param modisCred MODIS username and password in character vector c(username,password). See details. #' @return #' @export #' #' @examples modis_data_retrieval <- function(startDate, endDate, sfObject, param = "CWU", dataFolder, modisCred)

#——- Sanity checks and assertions before processing ———————-

#——- Processing ———————————————————-

# Load the template JSON file shipped with this package templateFile <- system.file("extdata", "ET.json", package = "downstreamness") templateJSON <- RJSONIO::fromJSON(templateFile)

# Compute the MODIS tiles modisTilesNr <- downstreamness::modis_tiles(sfObject)

# Edit it according to the settings templateJSON$start_date <- startDate templateJSON$end_date <- endDate templateJSON$user <- modisCred[1] templateJSON$password <- modisCred[2] templateJSON$output_proj4 <- sf::st_crs(sfObject)$proj4string templateJSON$out_folder <- dataFolder templateJSON$out_folder_mod <- paste(dataFolder, "raw", sep = "/") templateJSON$bbox <- as.integer(sf::st_bbox(sfObject)) templateJSON$scale_val <- "Yes" templateJSON$start_x <- modisTilesNr["Hmin"] templateJSON$end_x <- modisTilesNr["Hmax"] templateJSON$start_y <- modisTilesNr["Vmin"] templateJSON$end_y <- modisTilesNr["Vmax"]

# Write the JSON file to a temporary location tmp.json <- tempfile() write(RJSONIO::toJSON(templateJSON), tmp.json)

# Execute MODIStsp MODIStsp::MODIStsp(gui = FALSE, options_file = tmp.json)

# Locate the RData file rdata.folder <- paste(dataFolder, "Net_ET_8Day_500m_v6", "Time_Series", "RData", "Mixed", sep = "/") rdata.file <- list.files(rdata.folder, recursive = TRUE, pattern = "\.RData$", full.names = TRUE)

# Load the RData file load(rdata.file)

Value

A named character vector containing the H and V min and max.


mcdesignnl/downstreamness documentation built on May 21, 2019, 11:10 a.m.