Sf: Feature request: st_buffer single-sided support via GEOSOffsetCurve

Created on 8 Mar 2019  路  9Comments  路  Source: r-spatial/sf

I'd like to be able to make single-sided buffers of LINESTRING objects. Has this functionality been on anyone's radar?

It seems tricky to produce single-sided buffers in R using other methods, such as this or this, except for the special cases these examples describe. People make single-sided buffers with other spatial software, suggesting it's a function that would be useful.

The functionality to make single-sided buffers appears to be offered by GEOSOffsetCurve within geos_c.h and the interface looks similar to the functions already used by st_buffer. Would this be straightforward to incorporate?

Thanks very much for your work on this package.

feature

Most helpful comment

This now gives a single-sided buffer with

plot(st_buffer(st_linestring(rbind(c(0,0), c(10,0))), -2, singleSide=T), axes=T)

the direction being determined by the sign of the buffer size.

All 9 comments

Sounds like a good plan, and relatively straightforward. PR's welcome!

Hi

I am also interested in this feature or a similar feature. When I read the documentation of st_buffer, In the details section, it indicates that st_buffer functionality is based/inspired (?) on ST_Buffer of postgis.

And that postgis page shows a parameter side which seems to address this issue. So would it be easier to implement this into R sf package?

thank you.

It uses the same library (GEOS) that postgis uses. I can't really figure this out from reading geos_c.h. @dbaston do you have an idea?

You can see how PostGIS calls GEOS for a single-sided (polygonal) buffer here

But I think this ticket was about offsetting a line via GEOSOffsetCurve...which can be seen here

Thanks! I think this ticket was about the single-sided buffer, I don't see how GEOSOffsetCurve can give a buffer.

Yes, I misread the ticket and thought that a linestring _output_ was desired. That not being the case, GEOSBufferWithParams would be the way to go.

This now gives a single-sided buffer with

plot(st_buffer(st_linestring(rbind(c(0,0), c(10,0))), -2, singleSide=T), axes=T)

the direction being determined by the sign of the buffer size.

Thank you, how long does it take to get into CRAN or do you advice via devtools?

I don't know; I merged this into master, so it's the next release - 1 month from now, or earlier since we see an error on one of the CRAN check machines.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faridcher picture faridcher  路  4Comments

kendonB picture kendonB  路  4Comments

dpprdan picture dpprdan  路  4Comments

thiagoveloso picture thiagoveloso  路  3Comments

duleise picture duleise  路  3Comments