Closed ksamuk closed 9 years ago
Hi Kieran,
The huge value you report is due to the fact that both of your points (starting and ending points) have a depth value that lies outside the range of possible values you used to create your transition matrix. Here, you allowed a path at sea between -10m and -500m, but your starting and ending points have a positive altitude:
get.depth(bat, loc, locator = FALSE)
lon lat depth
1 -149.7565 61.61380 82
2 -61.9600 45.63197 35
A huge cost is thus added in the transition matrix, resulting in the seemingly incoherent value you report.
More generally, such results are observed when starting and ending points cannot be connected by staying within the given depth/altitude range specified when creating the transition matrix. This is often the case when working at large scales since points located very close to the shoreline may end up being positioned on land when using not-so-precise bathymetric data.
Here are two possible workarounds:
get.depth()
function to help you find the good spot. The function dist2isobath()
can also help you find the closest locations near your starting and ending points with a suitable depth of -10m. This is probably the best solution since you should not have to move your points too far away from their "real" locations. This will thus alter the distance results only very slightly.In your case:
new.loc <- dist2isobath(bat, loc, isobath=-10)
new.loc
distance start.lon start.lat end.lon end.lat
1 60875.24 -149.7565 61.61380 -150.58333 61.23611
2 19833.29 -61.9600 45.63197 -61.76894 45.75000
The great circle distances are given in meters. So here, your distance computation would be altered by 80km at most, which seems reasonable given the scale of you map:
(least.cost.distance <- lc.dist(tr, new.loc[,4:5], res="dist")[1])
[1] 9862
I hope this helps. Please, feel free to get back to us if you can't sort it out.
Happy marmaping! Best Benoit
Hi Benoit,
Great, thanks for your help! That all makes sense to me. The dist2isobath()
function is perfect for my application, so I think I will go with workaround 2. Thanks again!
Kieran
Great! I close this issue then. Best Benoit
Hi! First, this is a great package and I want to thank you for taking the time to develop it. I have run into a small issue:
I am getting strangely large values from
lc.dist()
That's...a large number! Here is the
lc.dist(res = "path")
plotted for the sameloc
So, something seemed off, so I wrote a quick function using
deg.dist()
from thefossil
library. This function just sums thepairwisesequential distances between points in thelc.dist()
pathand so running:
Which seems to make more sense. I'm not exactly sure what's going on here, but I thought I'd let you know. Any input would be greatly appreciated.