I would like to calculate distances between cities using Delaunay Triangulations. I have the longitudes and latitudes of the twenty cities I would like to calculate distances between, but I have some trouble figuring out how to extract the distance information out of the triangulation. I've used deldir() (from library deldir) so far. See the code below.
x <- c(2.3,3.0,7.0,1.0,3.0,8.0)
y <- c(2.3,3.0,2.0,5.0,8.0,9.0)
try <- deldir(x,y,list(ndx=2,ndy=2),c(0,10,0,10))
str(try)
List of 8
$ delsgs :'data.frame': 23 obs. of 6 variables:
..$ x1 : num [1:23] 3 7 7 1 1 3 3 3 8 8 ...
..$ y1 : num [1:23] 3 2 2 5 5 8 8 8 9 9 ...
..$ x2 : num [1:23] 2.3 2.3 3 2.3 3 3 7 1 7 3 ...
..$ y2 : num [1:23] 2.3 2.3 3 2.3 3 3 2 5 2 8 ...
..$ ind1: num [1:23] 2 3 3 4 4 5 5 5 6 6 ...
..$ ind2: num [1:23] 1 1 2 1 2 2 3 4 3 5 ...
$ dirsgs :'data.frame': 15 obs. of 8 variables:
..$ x1 : num [1:15] 1.65 4.56 5.75 0 1.65 ...
..$ y1 : num [1:15] 3.65 0.74 5.5 2.86 3.65 ...
..$ x2 : num [1:15] 4.56 4.51 4.56 1.65 3.5 ...
..$ y2 : num [1:15] 0.74 0 0.74 3.65 5.5 ...
..$ ind1: num [1:15] 2 3 3 4 4 5 5 5 6 6 ...
..$ ind2: num [1:15] 1 1 2 1 2 2 3 4 3 5 ...
..$ bp1 : logi [1:15] FALSE FALSE FALSE TRUE FALSE FALSE ...
..$ bp2 : logi [1:15] FALSE TRUE FALSE FALSE FALSE FALSE ...
$ summary :'data.frame': 10 obs. of 9 variables:
..$ x : num [1:10] 2.3 3 7 1 3 8 0 10 0 10
..$ y : num [1:10] 2.3 3 2 5 8 9 0 0 10 10
..$ n.tri : num [1:10] 4 4 6 5 5 5 4 3 4 2
..$ del.area: num [1:10] 4.5 6.05 18.67 7.5 15 ...
..$ del.wts : num [1:10] 0.045 0.0605 0.1867 0.075 0.15 ...
..$ n.tside : num [1:10] 4 4 5 4 5 3 1 1 2 1
..$ nbpt : num [1:10] 4 0 4 2 2 4 2 2 2 2
..$ dir.area: num [1:10] 9.09 10.74 23.32 9.39 18.06 ...
..$ dir.wts : num [1:10] 0.0909 0.1074 0.2332 0.0939 0.1806 ...
$ n.data : int 6
$ n.dum : int 4
$ del.area: num 100
$ dir.area: num 100
$ rw : num [1:4] 0 10 0 10
- attr(*, "class")= chr "deldir"
I am quite sure that somewhere in 'try' the distances between the points calculated by deldir are stored, but I just don't know where. I have tried figuring it out by calculating the distances and looking for the values among the $ elements, but I could not find them. For me, the best way to use this information would be if I could plot the length of each lines on the plot onto each individual line, then I can calculate the distances between all of the cities by hand.
Thanks for your help!