diff --git a/momepy/elements.py b/momepy/elements.py index d09f324c..752b5291 100644 --- a/momepy/elements.py +++ b/momepy/elements.py @@ -506,7 +506,9 @@ def _enclosed_tessellation( ) tessellation = pd.concat(new) - return tessellation.append(clean_blocks).reset_index(drop=True) + return tessellation.append(clean_blocks.drop(columns="position")).reset_index( + drop=True + ) def _tess( self, @@ -966,8 +968,9 @@ def enclosures( primary_barriers : GeoDataFrame, GeoSeries GeoDataFrame or GeoSeries containing primary barriers. (Multi)LineString geometry is expected. - limit : GeoDataFrame, GeoSeries (default None) - GeoDataFrame or GeoSeries containing external limit of enclosures, + limit : GeoDataFrame, GeoSeries, shapely geometry (default None) + GeoDataFrame, GeoSeries or shapely geometry containing external limit + of enclosures, i.e. the area which gets partitioned. If None is passed, the internal area of ``primary_barriers`` will be used. additional_barriers : GeoDataFrame @@ -990,6 +993,8 @@ def enclosures( """ if limit is not None: + if isinstance(limit, BaseGeometry): + limit = gpd.GeoSeries([limit]) if limit.geom_type.isin(["Polygon", "MultiPolygon"]).any(): limit_b = limit.boundary else: diff --git a/tests/test_elements.py b/tests/test_elements.py index 6fc06a84..b816493b 100644 --- a/tests/test_elements.py +++ b/tests/test_elements.py @@ -142,10 +142,14 @@ def test_enclosures(self): assert len(basic) == 7 assert isinstance(basic, gpd.GeoDataFrame) - limited = mm.enclosures(self.df_streets, gpd.GeoSeries([self.limit])) + limited = mm.enclosures(self.df_streets, self.limit) assert len(limited) == 20 assert isinstance(limited, gpd.GeoDataFrame) + limited2 = mm.enclosures(self.df_streets, gpd.GeoSeries([self.limit])) + assert len(limited2) == 20 + assert isinstance(limited2, gpd.GeoDataFrame) + b = self.limit.bounds additional_barrier = gpd.GeoSeries([LineString([(b[0], b[1]), (b[2], b[3])])])