Shapely Buffering, not working as expected

633 Views Asked by At

Why does buffering one of my geometries have an unexpected hole in it?

from shapely import LineString
from geopandas import GeoDataFrame

l = LineString([
  (250,447),
  (319,446),
  (325,387),
  (290,374),
  (259,378),
  (254,385),
  (240,409),
  (244,440),
  (250,447),
])

assert l.is_valid
assert l.is_simple

GeoDataFrame({'geometry': [
  l,
  l.buffer(80),
]}).plot(column='geometry')

holey buffered geometry

  • By removing a pair of coordinates, it doesn't have a hole.
  • When using Sedona's ST_Buffer this happened in more cases.
1

There are 1 best solutions below

5
On
from shapely import LineString
from geopandas import GeoDataFrame

l = LineString([
  (250,447),
  (319,446),
  (325,387),
  (290,374),
  (259,378),
  (254,385),
  (240,409),
  (244,440),
  (250,447),
])

l = l.simplify(tolerance=1e-6)

buffered_geometry = l.buffer(80, cap_style=3, join_style=2)

GeoDataFrame({'geometry': [l, buffered_geometry]}).plot(column='geometry')

which is basically what you did.

enter image description here