momepy.Tessellation#
- class momepy.Tessellation(gdf, unique_id, limit=None, shrink=0.4, segment=0.5, verbose=True, enclosures=None, enclosure_id='eID', threshold=0.05, use_dask=True, n_chunks=None, **kwargs)[source]#
Generates tessellation.
Three versions of tessellation can be created:
Morphological tessellation around given buildings
gdf
within setlimit
.Proximity bands around given street network
gdf
within setlimit
.Enclosed tessellation based on given buildings
gdf
withinenclosures
.
Pass either
limit
to create morphological tessellation or proximity bands orenclosures
to create enclosed tessellation.See [Fleischmann et al., 2020] for details of implementation of morphological tessellation and [Araldi and Fusco, 2019] for proximity bands.
Tessellation requires data of relatively high level of precision and there are three particular patterns causing issues.
1. Features will collapse into empty polygon - these do not have tessellation cell in the end.
2. Features will split into MultiPolygon - at some cases, features with narrow links between parts split into two during ‘shrinking’. In most cases that is not an issue and resulting tessellation is correct anyway, but sometimes this result in a cell being MultiPolygon, which is not correct.
3. Overlapping features - features which overlap even after ‘shrinking’ cause invalid tessellation geometry.
All three types can be tested prior
momepy.Tessellation
usingmomepy.CheckTessellationInput
.- Parameters
- gdfGeoDataFrame
GeoDataFrame containing building footprints or street network
- unique_idstr
name of the column with unique id
- limitMultiPolygon or Polygon (default None)
MultiPolygon or Polygon defining the study area limiting morphological tessellation or proximity bands (otherwise it could go to infinity).
- shrinkfloat (default 0.4)
distance for negative buffer to generate space between adjacent polygons (if geometry type of gdf is (Multi)Polygon).
- segmentfloat (default 0.5)
maximum distance between points after discretization
- verbosebool (default True)
if True, shows progress bars in loops and indication of steps
- enclosuresGeoDataFrame (default None)
Enclosures geometry. Can be generated using
momepy.enclosures()
.- enclosure_idstr (default ‘eID’)
name of the enclosure_id containing unique identifer for each row in
enclosures
. Applies only ifenclosures
are passed.- thresholdfloat (default 0.05)
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. Applies only if
enclosures
are passed.- use_daskbool (default True)
Use parallelised algorithm based on
dask.dataframe
. Requires dask. Applies only ifenclosures
are passed.- n_chunksNone
Number of chunks to be used in parallelization. Ideal is one chunk per thread. Applies only if
enclosures
are passed. Defualt automatically uses n == dask.system.cpu_count.
Examples
>>> tess = mm.Tessellation( ... buildings_df, 'uID', limit=mm.buffered_limit(buildings_df) ... ) Inward offset... Generating input point array... Generating Voronoi diagram... Generating GeoDataFrame... Dissolving Voronoi polygons... >>> tess.tessellation.head() uID geometry 0 1 POLYGON ((1603586.677274485 6464344.667944215,... 1 2 POLYGON ((1603048.399497852 6464176.180701573,... 2 3 POLYGON ((1603071.342637536 6464158.863329805,... 3 4 POLYGON ((1603055.834005827 6464093.614718676,... 4 5 POLYGON ((1603106.417554705 6464130.215958447,...
>>> enclosures = mm.enclosures(streets, admin_boundary, [railway, rivers]) >>> encl_tess = mm.Tessellation( ... buildings_df, 'uID', enclosures=enclosures ... ) >>> encl_tess.tessellation.head() uID geometry eID 0 109.0 POLYGON ((1603369.789 6464340.661, 1603368.754... 0 1 110.0 POLYGON ((1603368.754 6464340.097, 1603369.789... 0 2 111.0 POLYGON ((1603458.666 6464332.614, 1603458.332... 0 3 112.0 POLYGON ((1603462.235 6464285.609, 1603454.795... 0 4 113.0 POLYGON ((1603524.561 6464388.609, 1603532.241... 0
- Attributes
- tessellationGeoDataFrame
GeoDataFrame containing resulting tessellation
- For enclosed tessellation, gdf contains three columns:
geometry
,unique_id
matching with parental building,enclosure_id
matching with enclosure integer index
- gdfGeoDataFrame
original GeoDataFrame
- idSeries
Series containing used unique ID
- limitMultiPolygon or Polygon
limit
- shrinkfloat
used shrink value
- segmentfloat
used segment value
- collapsedlist
list of unique_id’s of collapsed features (if there are some) Applies only if
limit
is passed.- multipolygonslist
list of unique_id’s of features causing MultiPolygons (if there are some) Applies only if
limit
is passed.
- __init__(gdf, unique_id, limit=None, shrink=0.4, segment=0.5, verbose=True, enclosures=None, enclosure_id='eID', threshold=0.05, use_dask=True, n_chunks=None, **kwargs)[source]#
Methods
__init__
(gdf, unique_id[, limit, shrink, ...])