momepy.generate_blocks#

momepy.generate_blocks(tessellation, edges, buildings)[source]#

Generate blocks based on buildings, tessellation, and street network. Dissolves tessellation cells based on street-network based polygons. Links resulting ID to tessellation and returns blocks and tessellation ids.

Parameters:
tessellationGeoDataFrame

A GeoDataFrame containing morphological tessellation.

edgesGeoDataFrame

A GeoDataFrame containing a street network.

buildingsGeoDataFrame

A GeoDataFrame containing buildings.

Returns:
blocksGeoDataFrame

A GeoDataFrame containing generated blocks.

tessellation_idsSeries

A Series derived from morphological tessellation with block ID.

Notes

This function assumes morphological tessellation and 1:1 relationship between buildings and cells. Tesselation cells that do not have buildings can break the functionality.

Examples

>>> path = momepy.datasets.get_path("bubenec")
>>> buildings = geopandas.read_file(path, layer="buildings")
>>> streets = geopandas.read_file(path, layer="streets")

Generate tessellation:

>>> tessellation = momepy.morphological_tessellation(buildings)
>>> tessellation.head()
                                            geometry
0  POLYGON ((1603536.56 6464392.264, 1603541.262 ...
1  POLYGON ((1603167.679 6464323.194, 1603167.552...
2  POLYGON ((1603078.787 6464172.1, 1603077.665 6...
3  POLYGON ((1603070.306 6464154.611, 1603070.081...
4  POLYGON ((1603083.134 6464103.971, 1603077.387...
>>> blocks, tessellation_id = momepy.generate_blocks(
...     tessellation, streets, buildings
... )
>>> blocks.head()
                                            geometry
0  POLYGON ((1603421.741 6464282.377, 1603415.23 ...
1  POLYGON ((1603485.548 6464217.177, 1603483.228...
2  POLYGON ((1603314.034 6464117.593, 1603295.424...
3  POLYGON ((1602992.334 6464131.13, 1602992.334 ...
4  POLYGON ((1602992.334 6463992.499, 1602992.334...

tessellation_id can be directly assigned to its respective parental DataFrame directly.

>>> tessellation["block_id"] = tessellation_id