blocksnet.method.diversity
Classes
|
Provides methods for assessing the diversity of services in city blocks. |
- class blocksnet.method.diversity.Diversity(*, city_model: City, verbose: bool = True)[source]
Bases:
BaseMethod
Provides methods for assessing the diversity of services in city blocks.
- static plot(gdf: GeoDataFrame, linewidth: float = 0.1, figsize: tuple[int, int] = (10, 10))[source]
Plots diversity data for blocks on a map.
- Parameters:
gdf (geopandas.GeoDataFrame) – GeoDataFrame containing block geometries and diversity data.
linewidth (float, optional) – Line width for plotting the geometries, by default 0.1.
figsize (tuple of int, optional) – Size of the figure to plot, by default (10, 10).
- Return type:
None
- static _shannon_index(services_series) float [source]
Calculate the Shannon diversity index for given service counts.
- Parameters:
services_series (pandas.Series) – Series representing counts of different service types in a block.
- Returns:
The Shannon diversity index.
- Return type:
float
- calculate() GeoDataFrame [source]
Calculates the diversity of services for each block in the city model.
Diversity is determined using the Shannon diversity index based on the distribution of service types within each block.
- Returns:
GeoDataFrame containing blocks with calculated diversity of services.
- Return type:
geopandas.GeoDataFrame
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.