Skip to content

Commit 049f39b

Browse files
authored
Fix buffer without overlap (#630)
1 parent 676bf76 commit 049f39b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

geoutils/vector/geometric.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ def _buffer_metric(gdf: gpd.GeoDataFrame, buffer_size: float) -> gu.Vector:
4141

4242

4343
def _buffer_without_overlap(
44-
gdf: gpd.GeoDataFrame, buffer_size: int | float, metric: bool = True, plot: bool = False
44+
ds: gpd.GeoDataFrame, buffer_size: int | float, metric: bool = True, plot: bool = False
4545
) -> gu.Vector:
4646
"""See Vector.buffer_without_overlap() for details."""
4747

4848
# Project in local UTM if metric is True
4949
if metric:
50-
crs_utm_ups = _get_utm_ups_crs(df=gdf)
51-
gdf = gdf.to_crs(crs=crs_utm_ups)
50+
crs_utm_ups = _get_utm_ups_crs(df=ds)
51+
gdf = ds.to_crs(crs=crs_utm_ups)
5252
else:
53-
gdf = gdf
53+
gdf = ds
5454

5555
# Dissolve all geometries into one
5656
merged = gdf.dissolve()
@@ -111,7 +111,7 @@ def _buffer_without_overlap(
111111

112112
# Reverse-project to the original CRS if metric is True
113113
if metric:
114-
merged_voronoi = merged_voronoi.to_crs(crs=gdf.crs)
114+
merged_voronoi = merged_voronoi.to_crs(crs=ds.crs)
115115

116116
return gu.Vector(merged_voronoi)
117117

tests/test_vector/test_geometric.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def test_buffer_without_overlap(self, monkeypatch) -> None: # type: ignore
172172
# Output should be of same size as input and same geometry type
173173
assert len(buffer.ds) == len(two_squares.ds)
174174
assert np.all(buffer.ds.geometry.geom_type == two_squares.ds.geometry.geom_type)
175+
assert buffer.crs == two_squares.crs
175176

176177
# Extract individual geometries
177178
polys = []

0 commit comments

Comments
 (0)