View source: R/vis-make_transition2.r
make_transition2 | R Documentation |
Create transition layer for interpolate_path from SpatialPolygonsDataFrame.
make_transition2(poly, res = c(0.1, 0.1), extent_out = NULL, x_lim = NULL, y_lim = NULL)
poly |
A spatial polygon object of class SpatialPolygonsDataFrame. |
res |
two element vector that specifies the x and y dimension of output raster cells. Units of res are same as input polygon. |
extent_out |
An optional |
x_lim |
An optional two-element vector with extents of x axis. |
y_lim |
An optional two-element vector with extents of x axis. |
make_transition
uses rasterize to convert a
SpatialPolygonsDataFrame into a raster layer, and
geo-corrected transition layer transition. Raster cell
values on land = 0 and water = 1.
output transition layer is corrected for projection distortions using geoCorrection. Adjacent cells are connected by 16 directions and transition function returns 0 (land) for movements between land and water and 1 for all over-water movements.
A list with two elements:
a geo-corrected transition raster layer where land = 0
and water=1
(see gdistance
)
rasterized input layer of class raster
Todd Hayden, Tom Binder, Chris Holbrook
make_transition
library(sp) #for loading greatLakesPoly library(raster) # for plotting rasters # get polygon of the Great Lakes data(greatLakesPoly) #glatos example data; a SpatialPolygonsDataFrame # make_transition layer tst <- make_transition2(greatLakesPoly, res = c(0.1, 0.1)) # plot raster layer # notice land = 1, water = 0 plot(tst$rast) # plot transition layer plot(raster(tst$transition)) ## Not run: # increase resolution- this may take some time... tst1 <- make_transition2(greatLakesPoly, res = c(0.01, 0.01)) # plot raster layer plot(tst1$rast) # plot transition layer plot(raster(tst1$transition)) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.