Learn R Programming

leastcostpath (version 1.7.4)

crop_cs: Crop Cost Surface

Description

Crops Cost Surfaces to the supplied SpatialPolygon* boundary

Usage

crop_cs(cost_surface, boundary)

Arguments

cost_surface

TransitionLayer (gdistance package). Cost surface to crop

boundary

SpatialPolygons* (sp package). Boundary used when cropping Cost Surface

Value

TransitionLayer (gdistance package). Cropped Cost Surface

Details

The resultant Cost Surface is cropped to the SpatialPolygons* boundary. All areas of the Cost Surface that are outside the supplied boundary are given a conductance value of 0. The conductance value of 0 ensures that movement is inhibited within these areas.

Examples

Run this code
# NOT RUN {
r <- raster::raster(system.file('external/maungawhau.grd', package = 'gdistance'))
loc1 = cbind(2667670, 6479000)
loc1 = sp::SpatialPoints(loc1)
loc1 <- rgeos::gBuffer(spgeom = loc1, width = 200)
raster::crs(loc1) <- raster::crs(r)

slope_cs <- create_slope_cs(r, cost_function = 'tobler', neighbours = 16, max_slope = NULL)

slope_cs_cropped <- crop_cs(cost_surface = slope_cs, boundary = loc1)
# }

Run the code above in your browser using DataLab