costrasterGen {ipdw} | R Documentation |
Generate a cost Raster
Description
Generate a cost raster from an object of class sf with point or polygon geometries
Usage
costrasterGen(xymat, pols, extent = "polys", projstr, resolution = 1)
Arguments
xymat |
Matrix of coordinates or an sf object with point geometries |
pols |
sf object with polygon geometries |
extent |
Define extent based on extent of xymat/sf (points) or pols (polys). Default is polys. |
projstr |
proj4 string defining the output projection. A warning will be thrown if projstr does not match the projection of the extent target. Pass NULL for non-geographic grids. |
resolution |
Numeric defaults to 1. See |
Details
Ensure that the projection of the xymat coordinates and pols match. If they do not match use the st_transform
command.
Value
RasterLayer
See Also
Examples
## Not run:
library(sf)
Sr1 <- st_polygon(list(cbind(c(0, 0, 1, 1, 0), c(0, 12, 12, 0, 0))))
Sr4 <- st_polygon(list(cbind(c(9, 9, 10, 10, 9), c(0, 12, 12, 0, 0))))
Sr2 <- st_polygon(list(cbind(c(1, 1, 9, 9, 1), c(11, 12, 12, 11, 11))))
Sr3 <- st_polygon(list(cbind(c(1, 1, 9, 9, 1), c(0, 1, 1, 0, 0))))
Sr5 <- st_polygon(list(cbind(c(4, 4, 5, 5, 4), c(4, 8, 8, 4, 4))))
pols <- st_as_sf(st_sfc(Sr1, Sr2, Sr3, Sr4, Sr5,
crs = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
# using a matrix object
xymat <- matrix(3, 3, nrow = 1, ncol = 2)
costras <- costrasterGen(xymat, pols, projstr = NULL)
# plotting
plot(costras)
points(xymat)
## End(Not run)
[Package ipdw version 2.0-0 Index]