Solves the problem that buffers will not be circular when used on non-projected data.

buff_geo(shp, width, ...)

Arguments

shp

A spatial object with a geographic CRS (e.g. WGS84) around which a buffer should be drawn

width

The distance (in metres) of the buffer (when buffering sp objects)

...

Arguments passed to the buffer (see ?rgeos::gBuffer or ?sf::st_buffer for details)

Details

Returns a

Examples

r <- routes_fast[1:3, ] buff <- buff_geo(r, width = 100)
#> Transforming to CRS +proj=aeqd +lat_0=53.82763236 +lon_0=-1.53163002 +x_0=0 +y_0=0 +ellps=WGS84
plot(buff)
#> Error in as.double(y): cannot coerce type 'S4' to vector of type 'double'
plot(r, add = TRUE)
#> Error in as.double(y): cannot coerce type 'S4' to vector of type 'double'
# Test it works the same on projected data shp <- sp::spTransform(r, sp::CRS("+init=epsg:27700")) buff2 <- buff_geo(shp, 50) # test if it works the same on projected data plot(buff2)
#> Error in as.double(y): cannot coerce type 'S4' to vector of type 'double'
plot(r, add = TRUE) # note they do not show
#> Error in as.double(y): cannot coerce type 'S4' to vector of type 'double'
buff3 <- sp::spTransform(buff2, sp::CRS("+init=epsg:4326")) plot(buff)
#> Error in as.double(y): cannot coerce type 'S4' to vector of type 'double'
plot(buff3, add = TRUE, col = "black")
#> Error in as.double(y): cannot coerce type 'S4' to vector of type 'double'