View source: R/vis-make_transition.r
jarasterize | R Documentation |
An 'all-touched-capable' rasterizer that depends only on sf
and raster
.
jarasterize(
x,
res,
value = 1,
bg_value = 0,
all_touched = TRUE,
silent = FALSE
)
x |
An |
res |
Resolution (raster cell size) in units of |
value |
The value assigned to cells matching |
bg_value |
The value assigned to cells not matching |
all_touched |
If |
silent |
If false (default), progress messages are not displayed. |
A raster::rasterLayer
object.
# Example 1. lon lat WGS input
poly1 <- great_lakes_polygon
plot(sf::st_geometry(poly1))
rast1 <- jarasterize(poly1, res = c(0.1, 0.05))
## Not run:
# compare to polygon
x11(width = 12, height = 8)
raster::plot(rast1)
plot(sf::st_geometry(poly1), add = TRUE)
## End(Not run)
# Example 2. projected input; 5 km cell size
poly2 <- sf::st_transform(poly1, crs = 3175)
rast2 <- jarasterize(poly2, res = 5000)
## Not run:
# compare to polygon
x11(width = 12, height = 8)
raster::plot(rast2)
plot(sf::st_geometry(poly2), add = TRUE)
## End(Not run)
# Example 3. projected input; 5 km cell size; all_touched = FALSE
rast3 <- jarasterize(poly2, res = 5000, all_touched = FALSE)
## Not run:
# compare to polygon
x11(width = 12, height = 8)
raster::plot(rast3)
plot(sf::st_geometry(poly2), add = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.