Created
February 2, 2018 10:58
-
-
Save scottpdawson/2ad6a56e756f3bf028fed77f7152e741 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(plotKML) | |
# Find GPX files using a pattern | |
files <- dir(pattern = "\\.gpx") | |
# Consolidate routes in one drata frame | |
index <- c() | |
latitude <- c() | |
longitude <- c() | |
for (i in 1:length(files)) { | |
route <- readGPX(files[i]) | |
location <- route$tracks[[1]][[1]] | |
index <- c(index, rep(i, dim(location)[1])) | |
latitude <- c(latitude, location$lat) | |
longitude <- c(longitude, location$lon) | |
} | |
routes <- data.frame(cbind(index, latitude, longitude)) | |
# Map the routes | |
ids <- unique(index) | |
plot(routes$longitude, routes$latitude, type="n", axes=FALSE, xlab="", ylab="", main="", asp=1) | |
for (i in 1:length(ids)) { | |
currRoute <- subset(routes, index==ids[i]) | |
lines(currRoute$longitude, currRoute$latitude, col="#53116820") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment