In R, I have polygon layer A and point layer B. Both have the same number of features, there is one-to-one correspondence (pairing): each polygon of the layer A has a corresponding point in layer B and vice versa. How do I compute pairwise distances between these pairs of features?
I tried to use
gDistance(A, B, byid = TRUE)
but this will compute the whole N2 matrix, which is huge overhead (I would only use the diagonal of that matrix).