title: R Draw Circle with Radius (r metres) in Lat/Lon (epsg 4326)
body: <p>I would like to create a buffer for around 100 points in my data-set which is of length r and varies between the points (basically it's an 80th percentile distance that customers are willing to travel to get to the point/shop).</p>
  
  <p>My data contains the following columns: <strong>lat_centre, lon_centre, radius_km</strong></p>
  
  <p><strong>Here is a 1km example:</strong></p>
  
  <p>Javascript with Google Maps.</p>
  
  <pre><code>   var draw_circle = new google.maps.Circle({
          center: point_i,
          radius: 1000,
          strokeColor: col,
          strokeOpacity: 0.15,
          strokeWeight: 2,
          fillColor: col,
          fillOpacity: 0.15,
          map: map
      });
  </code></pre>
  
  <p>Which draws the image on the left:</p>
  
  <p><a href="https://i.stack.imgur.com/anXY9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/anXY9.png" alt="JS on left, R on right"></a></p>
  
  <p>However, the following R-attempt draws the circle on the right (which you can see is smaller):</p>
  
  <pre><code>library(dismo)
  emory &lt;- gmap("Bishopsgate, London", zoom = 14, scale = 2)
  d &lt;- data.frame(lat = c(51.51594), lon = c(-0.08248))
  coordinates(d) &lt;- ~ lon + lat
  projection(d) &lt;- "+init=epsg:4326"
  
  mm &lt;- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"
  d_mrc &lt;- spTransform(d, CRS = CRS(mm))
  
  # Buffer creation
  d_mrc_bff &lt;- gBuffer(d_mrc, width = 1000)
  library(scales) # for `alpha()` function
  
  plot(emory)
  plot(d_mrc_bff, col = alpha("red", .35), add = TRUE)
  points(d_mrc, cex = 2, pch = 20)
  </code></pre>