srs.line: Draw a Simple Random Sample (SRS) from a linear resource.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/srs.line.r

Description

Draws a simple random sample from a SpatialLines* object. The SpatialLines* object represents a 2-dimensional line resource, such as a river, highway, or coastline.

Usage

1
srs.line(x, n)

Arguments

x

A SpatialLines or SpatialLinesDataFrame object. This object must contain at least 1 line.

n

Sample size. Number of points to draw from the set of all lines contained in x.

Details

If x contains multiple lines, the lines are amalgamated before sampling. Conceptually, under amalgamation the lines in x are "stretched" straight and laid end-to-end in order of appearance in x. The simple random sample is then drawn from the amalgamated line. Once drawn from the 1-D amalgamated line, sample points are mapped back to 2-dimensional space to fall on the lines in x.

Note that the line is not discretized prior to sampling. The sample points are selected from the set of continuous lines that contain an infinite number of points (up to machine precision anyway).

Value

A SpatialPointsDataFrame containing locations in the SRS sample, in order along the amalgamated line. Those on line 1 appear first, those on line 2 second, etc. Attributes of the sample points (in the embedded data frame) are as follows:

Additional attributes of the output object, beyond those which make it a SpatialPointsDataFrame, are:

Author(s)

Trent McDonald

See Also

srs.polygon, srs.point, sdraw

Examples

1
2
3
4
5
6
# Draw fixed number of equi-distant points
HI.samp <- srs.line( HI.coast, 100 )   
plot( HI.coast, col=rainbow(length(HI.coast)) )
points( HI.samp, col="red", pch=16 )

# Inspect attributes of points with [email protected]

SDraw documentation built on May 29, 2017, 6:14 p.m.