Created
July 8, 2014 04:11
-
-
Save jimmyodonnell/f702fb7f229fdf529728 to your computer and use it in GitHub Desktop.
Calculate coordinates for sampling points along large spatial transects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(geosphere) | |
# First, pick a starting point for one of the transects. | |
start.point.1 <- matrix(data = c(-122.54727, 47.57078), nrow=1) | |
# Set two other starting points, 1000 meters from the first, in opposite directions | |
start.point.2 <- destPoint(start.point.1, 30, 1000) | |
start.point.3 <- destPoint(start.point.1, 210, 1000) | |
# Pick the distances along each transect you want to sample | |
transect.pts <- c(4000, 2000, 1000, 500, 250, 125, 75, 50, 0) | |
# For each start point, give the coordinates for points along a bearing at the distances we set earlier. | |
transect.1 <- destPoint(start.point.1, 310, transect.pts) | |
transect.2 <- destPoint(start.point.2, 310, transect.pts) | |
transect.3 <- destPoint(start.point.3, 310, transect.pts) | |
# Bind them up into a data frame that you can then print up and drive/walk/boat to! | |
transect.coords <- rbind(transect.1, transect.2, transect.3) | |
transect <- c(rep("Transect1", 9), rep("Transect2", 9), rep("Transect3", 9)) | |
point <- rep(transect.pts, 3) | |
transects <- data.frame(transect, point, transect.coords) | |
write.csv(transects, "transects.csv") | |
# here's a simple plot, but you could display these over a map | |
plot(transects[,3:4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment