Learn R Programming

leastcostpath (version 2.0.12)

crop_cs: Crop conductanceMatrix to extent

Description

Crop conductanceMatrix to extent

Usage

crop_cs(x, extent)

Arguments

x

spatRaster

extent

sf object or terra SpatRaster. Extent obtained from object using terra::ext

Author

Joseph Lewis

Details

conductanceMatrix cropped to extent of supplied Sf object or terra SpatRaster. conductanceMatrix spatRaster dimensions and Matrix dimensions update to reflect cropped extent

Examples

Run this code

r <- terra::rast(system.file("extdata/SICILY_1000m.tif", package="leastcostpath"))

slope_cs <- create_slope_cs(x = r, cost_function = "tobler", neighbours = 4)

ext <- sf::st_as_sfc(sf::st_bbox(rasterise(slope_cs)))
ext <- sf::st_buffer(ext, dist = -75000)
ext <- sf::st_as_sf(ext)

slope_cs_cropped <- crop_cs(slope_cs, extent = ext)

Run the code above in your browser using DataLab