momepy.BlocksCount#
- class momepy.BlocksCount(gdf, block_id, spatial_weights, unique_id, weighted=True, verbose=True)[source]#
Calculates the weighted number of blocks. The number of blocks within neighbours defined in
spatial_weights
divided by the area covered by the neighbours.\[\]Adapted from [Dibble et al., 2017].
- Parameters:
- gdfGeoDataFrame
A GeoDataFrame containing morphological tessellation.
- block_idstr, list, np.array, pd.Series
- The name of the objects dataframe column,
np.array
, or
pd.Series
where block IDs are stored.
- The name of the objects dataframe column,
- spatial_weightslibpysal.weights
A spatial weights matrix.
- unique_idstr
The name of the column with a unique ID used as the
spatial_weights
index.- weigtedbool, default True
Return value weighted by the analysed area (
True
) or pure count (False
).- verbosebool (default True)
If
True
, shows progress bars in loops and indication of steps.
Examples
>>> sw4 = mm.sw_high(k=4, gdf='tessellation_df', ids='uID') >>> tessellation_df['blocks_within_4'] = mm.BlocksCount(tessellation_df, ... 'bID', ... sw4, ... 'uID').series
- Attributes:
- seriesSeries
A Series containing resulting values.
- gdfGeoDataFrame
The original GeoDataFrame.
- block_idSeries
A Series containing used block ID.
- swlibpysal.weights
The spatial weights matrix
- idSeries
A Series containing used unique ID.
- weightedbool
True
if the weighted value was used.
Methods
__init__
(gdf, block_id, spatial_weights, ...)