knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of xytract is to provide a generic basis for matching locations in time to raster data.
The interface is the xytract
function, with required arguments
x(date)
a function that can read the raster data for a given dateinputfiles
the dataframe of available files used by x
, with columns fullname
(the path to the file) and date
the start date-time of the file. It doesn't matter what projection the raster files are in, it's assumed that the query points are longlat and these will be projected to the projection of the raster data.
It's assumed that inputfiles are in order of date.
You can install the dev version of xytract from GitHub with:
devtools::install_github("mdsumner/xytract")
This is a basic example which shows you how to match a set of locations with time to raster data.
WIP
library(xytract) files_db <- get_example_data() ## define a function to read read_ice <- function(date, ...) { if (missing(date)) return(raster::raster(files_db$fullname[1])) catch <- list(...) stopifnot(length(date) == 1L) idx <- findInterval(date, files_db$date) raster::raster(files_db$fullname[idx]) } xyt <- tibble::tibble(x = seq(-180, 175, by = 5), y = 84, t = seq(min(files_db$date), max(files_db$date), length = length(x))) xyt$conc <- xytract(read_ice, xyt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.