Reputation: 25
I am using distHaversine, which takes two points and gives a distance, i.e.
distHaversine(c(35,-75),c(35.1,-74.9)) prints: [1] 11501.11
I have two matricies, A and B that are (m by 2) and (n by 2), i.e. A has m points and B has n points. How can I use distHaversine on A and B to get a m x n matrix of distances?
Upvotes: 1
Views: 207
Reputation: 1628
I hope you are using distHaversine
of geosphere
package.
If so, this could be of your help:
t(apply(a, 1, function(x)distHaversine(x, b)))
Upvotes: 1