make_transition2: Create transition layer from a spatial polygon

View source: R/vis-make_transition2.r

make_transition2R Documentation

Create transition layer from a spatial polygon

Description

Create transition layer for interpolate_path from SpatialPolygonsDataFrame.

Usage

make_transition2(poly, res = c(0.1, 0.1), extent_out = NULL,
  x_lim = NULL, y_lim = NULL)

Arguments

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 Extent object (see extent) that determines the extent of the output objects. Output extent will default to extent of input object poly if extent_out, and x_lim/y_lim are NULL (default).

x_lim

An optional two-element vector with extents of x axis.

y_lim

An optional two-element vector with extents of x axis.

Details

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.

Value

A list with two elements:

transition

a geo-corrected transition raster layer where land = 0 and water=1 (see gdistance)

rast

rasterized input layer of class raster

Author(s)

Todd Hayden, Tom Binder, Chris Holbrook

See Also

make_transition

Examples


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)


jsta/glatos documentation built on July 11, 2022, 7:01 a.m.