Builds a valid JSON formatted API request from either a tidy data frame with point based sub-tasks, or when a region of interest (roi) is specified coordinates (latitude/longitude) will be ignored and a bounding box for an sf or SpatRaster object will be used instead.
rs_build_task(df, roi, format = "geotiff")
a data frame with task name (task), subtask name (subtask), latitude, longitude, start (start) and end (end) date.
a region of interest defined by a SpatRaster or sf object, the roi will override any point based data provided as latittude-longitude coordinates in the data frame
file format of the downloaded data either geotiff (the default) or netcdf4
a valid AppEEARS JSON formatted task
# define a task as a tidy data frame
# multiple subtasks can be provided
df <- data.frame(
task = "task_name",
subtask = c("sub_task"),
latitude = c(36.206228),
longitude = c(-112.127134),
start = c("2018-01-01"),
end = c("2018-01-15"),
product = c("MCD12Q2.006"),
layer = c("Greenup")
)
# build a task
rs_build_task(df)
#> {"params":{"dates":[{"startDate":"01-01-2018","endDate":"01-15-2018"}],"layers":[{"product":"MCD12Q2.006","layer":"Greenup"}],"coordinates":[{"id":"1","longitude":-112.1271,"latitude":36.2062,"category":"sub_task"}]},"task_name":"task_name","task_type":"point"}