make_grid {starsExtra} | R Documentation |
Make 'stars' grid from 'sf' layer
Description
Create 'stars' raster grid from bounding box of 'sf' vector layer, possibly buffered, with specified resolution.
Usage
make_grid(x, res, buffer = 0)
Arguments
x |
An |
res |
Required grid resolution, in CRS units of |
buffer |
Buffer size around |
Value
A stars
raster with the grid, with all cell values equal to 1
Examples
# Sample 'sf' layer
x = st_point(c(0,0))
y = st_point(c(1,1))
x = st_sfc(x, y)
x = st_sf(x)
# Make grid
r = make_grid(x, res = 0.1, buffer = 0.5)
r[[1]][] = rep(1:3, length.out = length(r[[1]]))
# Plot
plot(r, axes = TRUE, reset = FALSE)
plot(st_geometry(x), add = TRUE, pch = 4, cex = 3, col = "red")
[Package starsExtra version 0.2.8 Index]