View source: R/functions_raster.R
create_raster_from_variables | R Documentation |
Fills a raster grid with variable values associated with geographic locations
create_raster_from_variables(
data,
site_locations,
grid,
site_crs = sf::st_crs(site_locations),
filename = ""
)
data |
A vector or two-dimensional object. Elements/rows correspond to
|
site_locations |
An object that described geographic locations of
|
grid |
A Raster* object used as template. |
site_crs |
The |
filename |
A character string. Passed to |
A raster::RasterLayer
(if data
is a vector) or
raster::RasterBrick
(if data
is two-dimensional).
if (requireNamespace("raster")) {
r <- raster::raster(
xmn = 0, xmx = 10,
ymn = 0, ymx = 10,
crs = "OGC:CRS84",
resolution = c(1, 1)
)
rv <- create_raster_from_variables(
data = 1:10,
site_locations = as_points(
0.5 + cbind(0:9, 0:9),
crs = "OGC:CRS84",
to_class = "sf"
),
grid = r
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.