Search code examples
rbufferspatialshapefileoverlapping

Create a buffer zone around a point of a shapefile which starts at a specific distance from point


I have a shapefile containing a few thousands of points. My goal is to create a buffer zone around each point which starts at a radius of 3 meters away of each point and ends at a radius of 15 meters.

I usually create buffer zones with st_buffer (sf package), however if I use st_buffer(df, 15) the area in the 3m circle around the point is also included.

I now created two different buffer zones for each point consisting of a 3 meter and a 15 meter radius. My idea was to bind them to together into one data frame containing each points ID and the the two buffer zones. However I am missing a function which could exclude the overlapping areas of each points buffer zones, without excluding the areas of overlapping buffer zones from different points. Does anyone have an idea?

Thanks for the help in this matter.


Solution

  • It helps if you include a reproducible example with enough data to recreate the problem. This ensures that solvers can be sure their fixes are correct and time won't be wasted. So, at the risk of being wrong, here is some code that generates some points, creates two buffers round each point and subtracts them using st_difference.

    library(sf)
    mm=matrix(1:6,,2)
    points=st_multipoint(mm)
    bufsouter = st_buffer(points, 0.5)
    bufsinner = st_buffer(points, 0.3)
    bufsdiff = st_difference(bufsouter, bufsinner)
    plot(bufsdiff, col='red')
    

    enter image description here