Buffer with the library SF
We have already shown you a buffer with the rgeos library. This time we show you in a video version how to use the st_buffer function from the sf library.
Code:
library(sf) railway <- read_sf("d:/GIS_in_R/rail.shp") plot(railway$geometry) summary(railway) buf <- st_buffer(railway,dist = 1000) plot(buf$geometry,col="red") plot(railway$geometry,add=TRUE) w <- rep(500,nrow(railway)) w[86] <- 2000 buf <- st_buffer(railway,dist = w) plot(buf$geometry,col="red") buf <- st_buffer(railway,dist = w,endCapStyle = "SQUARE") plot(buf$geometry)