momepy.Count#

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

Calculate the number of elements within an aggregated structure. Aggregated structures can typically be blocks, street segments, or street nodes (their snapepd objects). The right gdf has to have a unique ID of aggregated structures assigned before hand (e.g. using momepy.get_network_id()). If weighted=True, the number of elements will be divided by the area of length (based on geometry type) of aggregated elements, to return relative value.

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

Adapted from [Hermosilla et al., 2012] and [Feliciotti, 2018].

Parameters:
leftGeoDataFrame

A GeoDataFrame containing aggregation to analyse.

rightGeoDataFrame

A GeoDataFrame containing objects to analyse.

left_idstr

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

right_idstr

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

weightedbool (default False)

If True, count will be divided by the area or length.

Examples

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

A Series containing resulting values.

leftGeoDataFrame

The original left GeoDataFrame.

rightGeoDataFrame

The original right GeoDataFrame.

left_idSeries

A Series containing used left ID.

right_idSeries

A Series containing used right ID.

weightedbool

True if the weighted value was used.

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

Methods

__init__(left, right, left_id, right_id[, ...])