I am having some issues with spTransform and the gBuffer function. I basically have a polygon that I want to buffer with gBuffer (not with st_buffer for other reasons). For some reason the shapefiles change sides when buffering. I've tried buffering with different sizes and as I enlarge the polygon with a buffer up to 100m everything works fine. When enlarging up to 1000m it already changes shape to a sort of circle and then 10000m the shape has basically inverted. I have provided the code below.
# Read in data
plots <- readOGR("~/Documents/Shapefiles/Plots1.shp")
plots <- spTransform(plots, CRS("+proj=longlat +datum=WGS84")) # add projection
plot(plots[1,])
# Change projection to utm for buffer
plot <- spTransform(plots[1,], CRS("+proj=utm +init=epsg:4326"))
buf <- set_units(10000,'m')
buffer <- gBuffer(plot, width = buf, quadsegs = 1, capStyle = "FLAT")
plot(buffer)
buffer <- spTransform(buffer, CRSobj ="+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
plot(buffer)
#Change original polygon back to original CRS
polygons <- spTransform(plot,
CRSobj ="+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")
plot(polygons)