Learn R Programming

geospt (version 1.0-4)

samplePts: sample n point locations in (or on) a spatial object

Description

sample location points within a square area, a grid, a polygon, or on a spatial line, using regular or random sampling methods. The function spsample from the package sp is used iteratively to find exactly n sample locations

Usage

samplePts(x, n, type, ...)

Value

an object of class SpatialPoints-class

Arguments

x

Spatial object; see the sp package for details

n

exact sample size

type

character; "random" for completely spatial random; "regular" for regular (systematically aligned) sampling; "stratified" for stratified random (one single random location in each "cell"); "nonaligned" for nonaligned systematic sampling (nx random y coordinates, ny random x coordinates); "hexagonal" for sampling on a hexagonal lattice; "clustered" for clustered sampling; "Fibonacci" for Fibonacci sampling on the sphere. See the sp package for details

...

other arguments to be passed to spsample

See Also

See spsample in the sp package

Examples

Run this code
data(lalib)
hexPts <- samplePts(lalib, 5, "hexagonal")
plot(lalib, xlim=c(bbox(lalib)[1], bbox(lalib)[3]), ylim=c(bbox(lalib)[2],
    bbox(lalib)[4]))
plot(hexPts, add=TRUE)
if (FALSE) {
randomPts <- samplePts(lalib, 5, "random")
plot(lalib, xlim=c(bbox(lalib)[1], bbox(lalib)[3]), ylim=c(bbox(lalib)[2],
    bbox(lalib)[4]))
plot(randomPts, add=TRUE)
}

Run the code above in your browser using DataLab