-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dd9dee
commit 3977ff6
Showing
5 changed files
with
281 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import geopandas as gpd | ||
from .base_method import BaseMethod | ||
|
||
CONNECTIVITY_COLUMN = "connectivity" | ||
|
||
PLOT_KWARGS = { | ||
"column": CONNECTIVITY_COLUMN, | ||
"legend": True, | ||
"cmap": "cool", | ||
} | ||
|
||
|
||
class WeightedConnectivity(BaseMethod): | ||
""" | ||
Provides methods for block connectivity assessment taking into account population and services within urban blocks. | ||
Methods | ||
------- | ||
plot(gdf, linewidth=0.1, figsize=(10, 10)) | ||
Plots connectivity data on a map. | ||
calculate() | ||
Calculates connectivity for all blocks in the city model. | ||
""" | ||
|
||
@staticmethod | ||
def plot(gdf: gpd.GeoDataFrame, linewidth: float = 0.1, figsize: tuple[int, int] = (10, 10)): | ||
""" | ||
Plots connectivity data for blocks on a map. | ||
Parameters | ||
---------- | ||
gdf : geopandas.GeoDataFrame | ||
GeoDataFrame containing block geometries and connectivity 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). | ||
Returns | ||
------- | ||
None | ||
""" | ||
gdf.plot(linewidth=linewidth, figsize=figsize, **PLOT_KWARGS).set_axis_off() | ||
|
||
def calculate(self) -> gpd.GeoDataFrame: | ||
""" | ||
Calculates weighted connectivity for all blocks in the city model. | ||
Connectivity is determined by the median value of the accessibility matrix row for each block. | ||
Returns | ||
------- | ||
geopandas.GeoDataFrame | ||
GeoDataFrame containing blocks with calculated connectivity. | ||
""" | ||
blocks_gdf = self.city_model.get_blocks_gdf()[["geometry"]] | ||
blocks_gdf[CONNECTIVITY_COLUMN] = self.city_model.accessibility_matrix.median(axis=1) | ||
return blocks_gdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"path": "../../../../examples/methods/weighted_connectivity.ipynb" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.