momepy.enclosed_tessellation#
- momepy.enclosed_tessellation(geometry, enclosures, shrink=0.4, segment=0.5, threshold=0.05, n_jobs=-1)[source]#
Generate enclosed tessellation
Enclosed tessellation is an enhanced
morphological_tessellation()
, based on predefined enclosures and building footprints. We can see enclosed tessellation as two-step partitioning of space based on building footprints and boundaries (e.g. street network, railway). Original morphological tessellation is used under the hood to partition each enclosure.Tessellation requires data of relatively high level of precision and there are three particular patterns causing issues:
Features will collapse into empty polygon - these do not have tessellation cell in the end.
Features will split into MultiPolygons - in some cases, features with narrow links between parts split into two during ‘shrinking’. In most cases that is not an issue and the resulting tessellation is correct anyway, but sometimes this results in a cell being a MultiPolygon, which is not correct.
Overlapping features - features which overlap even after ‘shrinking’ cause invalid tessellation geometry.
All three types can be tested using
momepy.CheckTessellationInput
.The index of the resulting GeoDataFrame links the input buildings with the output geometry. Enclosures with no buildings are also included in the output with negative index. Ensure that the input geometry has unique non-negative index for this to work correctly.
- Parameters:
- geometryGeoSeries | GeoDataFrame
A GeoDataFrame or GeoSeries containing buildings to tessellate the space around.
- enclosuresGeoSeries | GeoDataFrame
The enclosures geometry, which can be generated using
momepy.enclosures()
.- shrinkfloat, optional
The distance for negative buffer to generate space between adjacent polygons). By default 0.4
- segmentfloat, optional
The maximum distance between points after discretization. By default 0.5
- thresholdfloat, optional
The minimum threshold for a building to be considered within an enclosure. Threshold is a ratio of building area which needs to be within an enclosure to inlude it in the tessellation of that enclosure. Resolves sliver geometry issues. If None, the check is skipped and all intersecting buildings are considered. By default 0.05
- n_jobsint, optional
The number of jobs to run in parallel. -1 means using all available cores. By default -1
- Returns:
- GeoDataFrame
GeoDataFrame with an index matching the index of input geometry and a column matching the index of input enclosures.
Warning
Due to the floating point precision issues in clipping the tessellation cells to the extent of their parental enclosures, the result does not form a precise polygonal coverage. To build a contiguity graph, use fuzzy contiguity builder with a small buffer, e.g.:
from libpysal import graph graph.Graph.build_fuzzy_contiguity(tessellation, buffer=1e-6)
See also
Examples
>>> path = momepy.datasets.get_path("bubenec") >>> buildings = geopandas.read_file(path, layer="buildings") >>> streets = geopandas.read_file(path, layer="streets")
Generate enclosures:
>>> enclosures = momepy.enclosures(streets)
Generate tessellation:
>>> momepy.enclosed_tessellation(buildings, enclosures).head() geometry enclosure_index 0 POLYGON ((1603572.779 6464354.58, 1603572.505 ... 0 113 POLYGON ((1603543.601 6464322.376, 1603543.463... 0 114 POLYGON ((1603525.157 6464283.592, 1603524.725... 0 125 POLYGON ((1603601.446 6464256.455, 1603600.982... 0 126 POLYGON ((1603528.593 6464221.033, 1603527.796... 0