title: Creating a buffer around a geographic point and then checking whether a list of coordinates is inside that buffer?
body: <p>I have the following puzzle regarding spatial data in R:</p>
  
  <p>I have a dataset with street segments (with their respective starting and ending coordinates). I want to create a buffer of X meters around these points and then check whether a list of lat/lon points is within that buffer. Is there a way to do this in R? </p>
  
  <p>I'm able to map the points and map the buffers using a combination of various packages: maptools, ggmap, rgdal, sp, and rgeos. But this procedure seems to only map the points and the buffers without allowing me to then check if the other coordinates I have are within the buffers. Ideally, I'd like to produce a vector of 1s and 0s describing whether the list of lat/lon points are within the buffer around the street segments.</p>
  
  <p>Any ideas?</p>
  
  <p>This is the code I've been using, but I get all missing values (and I know this shouldn't be the case). I've also tried using the gContains function from rgeos but it crashed R. </p>
  
  <pre><code>#Load shapefile in R and transform to appropriate CRS
  shp &lt;- readOGR(dsn="/Users/Maps/shapes", layer="shp")
  shp_transf &lt;- spTransform(shp_transf, CRS( "+init=epsg:21897" ))
  
  #Create buffer around polygons
  shp_buff &lt;- gBuffer(shp_transf, width=40, byid=TRUE, quadsegs=10)
  
  #Make my dataframe of lat/lon points into same projection as buffers
  points &lt;- SpatialPoints(points,proj4string=CRS(proj4string(shp_buff)))
  
  #Use over function from SP pacakge
  result &lt;- as.integer(over(points, shp_buff)$OBJECTID)
  </code></pre>