title: Compute pairwise distances between two layers: gDistance(byid = TRUE) but pairwise?
body: <p>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.
  <strong>How do I compute pairwise distances between these pairs of features?</strong></p>
  
  <p>I tried to use </p>
  
  <pre><code>gDistance(A, B, byid = TRUE)
  </code></pre>
  
  <p>but this will compute the whole NxN matrix, which is huge overhead (I would only use the diagonal of that matrix).</p>