Learn R Programming

secrlinear (version 1.2.4)

read.linearmask: Import Linear Habitat Mask

Description

Construct a linearmask from line data in a text file, a polyline shapefile, a dataframe or a SpatialLinesDataFrame object.

Usage

read.linearmask(file = NULL, data = NULL, spacing = 10, spacingfactor =
1.5, graph = TRUE, cleanskips = TRUE,  ...)

Value

A `linearmask' object, i.e. a `mask' object in which each point represents a line segment of length spacing, and with additional attributes `SLDF', `spacingfactor' and possibly `graph' (see

linearmask).

Arguments

file

file name

data

data frame or SpatialLinesDataFrame

spacing

length of each discretized segment

spacingfactor

numeric criterion for joining mask points

graph

logical; if TRUE the igraph representation of the mask is saved as an attribute

cleanskips

logical; if TRUE then cleanskips is applied to the graph

...

other arguments passed to read.table for file input

Details

Only one of `file' or `data' should be specified. The file name should include the extension (e.g., "silverstream.shp").

Input from a text file, polyline shapefile or dataframe is first converted to a SpatialLinesDataFrame object. Points are spaced equally along each SpatialLine, starting at spacing / 2.

For dataframe input via data the coordinates are expected to be in columns `x' and `y'; if these names are missing, or input is from a file, the first two columns are used.

spacingfactor is used by asgraph to determine which points are joined when computing distances. It should be between 1 and 2.

See Also

asgraph, linearmask, make.sldf, networkdistance, SpatialLinesDataFrame

Examples

Run this code

x <- seq(0, 4*pi, length = 200)
xy <- data.frame(x = x*100, y = sin(x)*300)
test <- read.linearmask(data = xy, spacing = 20)
plot(test)

xy2 <- data.frame(x = x*100, y = cos(x)*300)
test2 <- read.linearmask(data = xy2, spacing = 20)

plot(test2, add = TRUE)

Run the code above in your browser using DataLab