read.linearmask {secrlinear} | R Documentation |
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, ...)
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 |
... |
other arguments passed to |
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.
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).
Note
A valid shapefile includes at least three files with extensions ‘.shp’, ‘.dbf’ and ‘.shx’. The full name of the .shp file is provided as the ‘file’ argument of read.linearmask
.
Line-level covariates are copied from SpatialLinesDataFrame input. Point-specific covariates may be added
later using covariates
or addCovariates
.
See Also
asgraph
,
linearmask
,
make.sldf
,
networkdistance
,
SpatialLinesDataFrame
Examples
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)