blocksnet.method.integration

Classes

Integration(*, city_model[, verbose, graph])

A class for calculating and analyzing spatial integration in city blocks.

IntegrationType(value)

An enumeration.

WeightType(value)

An enumeration.

class blocksnet.method.integration.IntegrationType(value)[source]

Bases: Enum

An enumeration.

LOCAL = 'local'
GLOBAL = 'global'
class blocksnet.method.integration.WeightType(value)[source]

Bases: Enum

An enumeration.

ANGULAR = 'angle'
LENGTH = 'mm_len'
class blocksnet.method.integration.Integration(*, city_model: City, verbose: bool = True, graph: Graph | None = None)[source]

Bases: BaseMethod

A class for calculating and analyzing spatial integration in city blocks.

This class extends BaseMethod and includes methods for computing integration metrics based on spatial networks and clustering city blocks based on their integration characteristics.

Variables:

graph (Optional[nx.Graph]) – A network graph representing the city’s road network. If not provided, it is generated from the city’s block geometry.

graph: Graph | None
static validate_graph(graph)[source]

Validate and optionally generate the network graph from the city’s block geometry.

Parameters:

graph (Optional[nx.Graph]) – The network graph representing the city’s road network.

Returns:

The validated or generated network graph.

Return type:

nx.Graph

static validate_model(model)[source]

Validate the city model and generate the network graph if necessary.

Parameters:

model (dict) – A dictionary containing the city model and optionally an existing graph.

Returns:

The validated model dictionary with the graph.

Return type:

dict

static plot(gdf: GeoDataFrame, column: str, linewidth: float = 0.1, figsize=(10, 10))[source]

Plot the GeoDataFrame with a specified column.

Parameters:
  • gdf (gpd.GeoDataFrame) – The GeoDataFrame to plot.

  • column (str) – The column to use for coloring the plot.

  • linewidth (float) – Size of polygons’ borders, by default 0.1.

  • figsize (tuple of int, optional) – The size of the plot figure (default is (10, 10)).

Return type:

None

property blocks: GeoDataFrame

Get the GeoDataFrame of city blocks with their FSI (Floor Space Index) values.

Returns:

A GeoDataFrame containing the blocks’ geometries and FSI values.

Return type:

gpd.GeoDataFrame

property edges: GeoDataFrame

Get the GeoDataFrame of edges from the network graph.

Returns:

A GeoDataFrame containing the edges of the network graph.

Return type:

gpd.GeoDataFrame

_get_dual_graph() Graph[source]

Generate the dual graph of the city blocks based on their spatial intersections.

Returns:

The dual graph representing the spatial relationships between city blocks.

Return type:

nx.Graph

clusterize(integration_blocks: GeoDataFrame, columns=['fsi', 'integration'], n_clusters=4) GeoDataFrame[source]

Perform clustering on integration blocks based on specified columns.

Parameters:
  • integration_blocks (gpd.GeoDataFrame) – The GeoDataFrame containing blocks with integration metrics.

  • columns (list of str, optional) – The columns to use for clustering (default is [FSI_COLUMN, INTEGRATION_COLUMN]).

  • n_clusters (int, optional) – The number of clusters to form (default is 4).

Returns:

The GeoDataFrame with an additional column for cluster labels.

Return type:

gpd.GeoDataFrame

calculate(integration_type: IntegrationType | None = None, weight_type: WeightType = WeightType.ANGULAR, local_radius: int = 5) GeoDataFrame[source]

Calculate integration metrics for city blocks based on the specified integration type and weight type.

Parameters:
  • integration_type (IntegrationType, optional) – The type of integration to calculate (local or global). If None, no integration is calculated.

  • weight_type (WeightType, optional) – The type of weight to use for integration calculation (default is WeightType.ANGULAR).

  • local_radius (int, optional) – The radius for local integration calculation (default is 5).

Returns:

The GeoDataFrame with calculated integration metrics for each block.

Return type:

gpd.GeoDataFrame

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.