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

original polygon

# 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")
buffer <- spTransform(buffer,  CRSobj ="+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0") 

Buffer before spTransform Buffer after spTransform

#Change original polygon back to original CRS
polygons <- spTransform(plot, 
                        CRSobj ="+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0")  

Polygon after backtransformation

1 Answer 1


The gBuffer function needed a joinStyle = "MITRE" argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.