Skip to content

Instantly share code, notes, and snippets.

@josephlewis
Created April 6, 2018 21:44
Show Gist options
  • Save josephlewis/a4746293d093b86265527c3aaa9a3150 to your computer and use it in GitHub Desktop.
Save josephlewis/a4746293d093b86265527c3aaa9a3150 to your computer and use it in GitHub Desktop.
for (i in levels(scot_battles_centroid_dates$century)) { # the levels are "1200s" to "1900s"
battle_road_dist <- gDistance(scot_battles_centroid_dates[scot_battles_centroid_dates$century == i,], sp, byid = TRUE) # euclidean distance from battle point to road.
battle_road_dist_vect <- data.frame(as.vector(battle_road_dist)) # creates df of the distances
dist_test <- rbind(battle_road_dist_vect) # adds to a df to create one df with all of the distances
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment