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 returnsblocks
andtessellation
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 geometry 0 POLYGON ((1603577.153 6464348.291, 1603576.946... 1 POLYGON ((1603166.356 6464326.62, 1603166.425 ... 2 POLYGON ((1603006.941 6464167.63, 1603009.97 6... 3 POLYGON ((1602995.269 6464132.007, 1603001.768... 4 POLYGON ((1603084.231 6464104.386, 1603083.773...
>>> blocks, tessellation_id = momepy.generate_blocks( ... tessellation, streets, buildings ... ) >>> blocks.head() geometry 0 POLYGON ((1603500.079 6464214.019, 1603499.565... 1 POLYGON ((1603431.893 6464278.302, 1603431.553... 2 POLYGON ((1603321.257 6464125.859, 1603320.938... 3 POLYGON ((1603137.411 6464124.658, 1603137.116... 4 POLYGON ((1603179.384 6463961.584, 1603179.357...
tessellation_id
can be directly assigned to its respective parental DataFrame directly.>>> tessellation["block_id"] = tessellation_id