rasterizeLine {roads}R Documentation

Faster rasterize for lines

Description

Rasterize a line using stars because fasterize doesn't work on lines and rasterize is slow. Deprecated use terra::rasterize

Usage

rasterizeLine(sfLine, rast, value)

Arguments

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

Value

a RasterLayer where the value of cells that touch the line will be the row index of the line in the sf

Examples

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)


[Package roads version 1.1.1 Index]