View source: R/rasterizeLine.R
rasterizeLine | R Documentation |
Rasterize a line using stars
because fasterize
doesn't work on lines and
rasterize is slow. Deprecated use terra::rasterize
rasterizeLine(sfLine, rast, value)
sfLine |
an sf object to be rasterized |
rast |
a raster to use as template for the output raster |
value |
a number value to give the background ie 0 or NA |
a RasterLayer where the value of cells that touch the line will be the row index of the line in the sf
CLUSexample <- prepExData(CLUSexample)
roadsLine <- sf::st_sf(geometry = sf::st_sfc(sf::st_linestring(
matrix(c(0.5, 4.5, 4.5, 4.51),
ncol = 2, byrow = TRUE)
)))
# Deprecated rasterizeLine(roadsLine, CLUSexample$cost, 0)
# Use terra::rasterize
terra::rasterize(roadsLine, CLUSexample$cost, background = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.