Skip to content

unexpected multiple polygons from st_buffer with endCapStyle='FLAT' #2552

@mbedward

Description

@mbedward

Using sf 1.0-21, I have a pipeline that involves buffering linestrings with a constant buffer distance and endCapStyle='FLAT'. I've noticed that when a line is short relative to the buffer distance, additional disjunct polygons are sometimes generated. For example...

v <- matrix(c(
  245184.6, 6045650,
  245193.3, 6045649,
  245201.7, 6045651,
  245204.3, 6045653
), ncol=2, byrow=TRUE)

line <- st_sfc(st_linestring(v), crs=28356)

buf <- st_buffer(line, dist=50, endCapStyle = 'FLAT')

plot(buf, col="grey90")
plot(line, add=TRUE, lwd=2, col="darkred")
Image

However, if I generate two single-side buffers I get the desired flat end-cap style and the disjunct polygons are not created.

buf_left <- st_buffer(line, dist=50, singleSide = TRUE)
buf_right <- st_buffer(line, dist=-50, singleSide = TRUE)

plot(c(buf_left, buf_right), col="grey90")
plot(line, add=TRUE, lwd=2, col="darkred")
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions