twpayne / go-geom

Package geom implements efficient geometry types for geospatial applications.
BSD 2-Clause "Simplified" License
851 stars 105 forks source link

creating buffer around point #121

Open rayhaanq opened 5 years ago

rayhaanq commented 5 years ago

Hi, I was just wondering if it would be possible to create a buffer around a point. How would you implement this with this library? This would be the equivalent of ST_Buffer

aryehlev commented 2 years ago

206

twpayne commented 2 years ago

Creating a buffer around a single point is relatively straightforward: the resulting geometry is a circle (likely simplified to a polygon with an appropriate number of points).

ST_Buffer is significantly more complicated to implement as it works on arbitrary geometries. As a simple example, ST_Buffer around two identical points returns a single circle (possibly simplified to polygon), ST_Buffer around two neighboring points returns the union of two overlapping circles (still representable as a polygon), and ST_Buffer around two well-separated points returns two non-overlapping circles (now only representable as a multipolygon).

If you need this functionality, GEOS is a tried and tested library for these operations. go-geos provides Go bindings to it, but comes with many caveats. This is not an easy problem.