I have a Shapefile of railroads in Mozambique, and have generated 100 random points along the railroad using the code below.
My question is pretty simple, but I can't find an answer: how do you calculate the distance between points along the railroad?
I do not want the Euclidean distance, I want the distance from Point A to Point B, going along the railroad tracks.
Thanks in advance!
library(sp)
library(rgdal)
library(spgrass6)
library(maptools)
library(igraph)
library(fields)
railroads <- readShapeLines("MOZ_rails.shp")
#Generate 100 random points, and put them on a matrix:
RandomPoints<-spsample(railroads, 100, type="random")