Every fisherman has a "honey hole," where they can get a good catch on almost any day of the year. However, as fish biologist we are after a good representation, not a "greatest hits." We might want to know, for example, the relationship between a species' presence and substrate particle size classes in a creek—meaning we need a good representation of the range of particle size in the creek. But sampling the entire creek would be really time consuming!

Enter random sampling. We can get estimates of how represented particle size classes are by randomly choosing locations along the creek. There have been a few ways developed to do this. Below is a code snippet that uses 'sp' the default packages of R to randomly select sampling locations along a creek (or any "line" in coordinate space).

library(sp)
x <- c(-89.00899, -89.00882, -89.00845, -89.00775)
y <- c(33.25582, 33.25565, 33.25548, 33.25551)
xy <- cbind(x, y)
creek <- sp::Line(xy)
n <- 5
pnts <- spsample(creek, n = n, 'random')
plot(xy, type = 'l')
points(pnts)
coordinates(pnts)

This snippet produces figures, like the one in the below and the one below, and reports the random coordinates back to you.

Base 64 graphics may not be rendered in IE-use chrome or firefox