momepy.Count

class momepy.Count(left, right, left_id, right_id, weighted=False)[source]

Calculate the number of elements within an aggregated structure.

Aggregated structure can be typically block, street segment or street node (their snapepd objects). Right gdf has to have unique id of aggregated structure assigned before hand (e.g. using momepy.get_network_id()). If weighted=True, number of elements will be divided by the area of lenght (based on geometry type) of aggregated element, to return relative value.

\[\sum_{i \in aggr} (n_i);\space \frac{\sum_{i \in aggr} (n_i)}{area_{aggr}}\]
Parameters:
left : GeoDataFrame

GeoDataFrame containing aggregation to analyse

right : GeoDataFrame

GeoDataFrame containing objects to analyse

left_id : str

name of the column where is stored unique ID in left gdf

right_id : str

name of the column where is stored unique ID of aggregation in right gdf

weighted : bool (default False)

if weighted=True, count will be divided by the area or length

References

1. Hermosilla T, Ruiz LA, Recio JA, et al. (2012) Assessing contextual descriptive features for plot-based classification of urban areas. Landscape and Urban Planning, Elsevier B.V. 106(1): 124–137. 2. Feliciotti A (2018) RESILIENCE AND URBAN DESIGN:A SYSTEMS APPROACH TO THE STUDY OF RESILIENCE IN URBAN FORM. LEARNING FROM THE CASE OF GORBALS. Glasgow.

Examples

>>> blocks_df['buildings_count'] = mm.Count(blocks_df, buildings_df, 'bID', 'bID', weighted=True).series
Attributes:
series : Series

Series containing resulting values

left : GeoDataFrame

original left GeoDataFrame

right : GeoDataFrame

original right GeoDataFrame

left_id : Series

Series containing used left ID

right_id : Series

Series containing used right ID

weighted : bool

used weighted value

__init__(self, left, right, left_id, right_id, weighted=False)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, left, right, left_id, right_id) Initialize self.