class momepy.BlocksCount(gdf, block_id, spatial_weights, unique_id, weighted=True)[source]

Calculates the weighted number of blocks

Number of blocks within neighbours defined in spatial_weights.

gdf : GeoDataFrame

GeoDataFrame containing morphological tessellation

block_id : str, list, np.array, pd.Series

the name of the objects dataframe column, np.array, or pd.Series where is stored block ID.

spatial_weights : libpysal.weights

spatial weights matrix

unique_id : str

name of the column with unique id used as spatial_weights index

weigted : bool, default True

return value weighted by the analysed area (True) or pure count (False)


Dibble J, Prelorendjos A, Romice O, et al. (2017) On the origin of spaces: Morphometric foundations of urban form evolution. Environment and Planning B: Urban Analytics and City Science 46(4): 707–730.


>>> sw4 = mm.sw_high(k=4, gdf='tessellation_df', ids='uID')
>>> tessellation_df['blocks_within_4'] = mm.BlocksCount(tessellation_df, 'bID', sw4, 'uID').series
series : Series

Series containing resulting values

gdf : GeoDataFrame

original GeoDataFrame

block_id : Series

Series containing used block ID

sw : libpysal.weights

spatial weights matrix

id : Series

Series containing used unique ID

weighted : bool

used weighted value

__init__(self, gdf, block_id, spatial_weights, unique_id, weighted=True)[source]

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


__init__(self, gdf, block_id, …[, weighted]) Initialize self.