blocksnet.method.spacematrix

Classes

Spacematrix(*, city_model[, verbose, ...])

Provides methods for calculating and visualizing urban block morphotypes based on the Spacematrix model.

class blocksnet.method.spacematrix.Spacematrix(*, city_model: City, verbose: bool = True, number_of_clusters: int = 11, random_state: int = 10)[source]

Bases: BaseMethod

Provides methods for calculating and visualizing urban block morphotypes based on the Spacematrix model.

Variables:
  • number_of_clusters (int) – Number of clusters for KMeans clustering.

  • random_state (int) – Random state for reproducibility of clustering results.

plot(gdf, linewidth=0.1, figsize=(10, 10))[source]

Plots Spacematrix morphotypes on a map.

calculate() gpd.GeoDataFrame[source]

Calculates Spacematrix and Strelka morphotypes for urban blocks.

number_of_clusters: int
random_state: int
static plot(gdf, linewidth: float = 0.1, figsize: tuple[int, int] = (10, 10))[source]

Plots Spacematrix morphotypes for blocks on a map.

Parameters:
  • gdf (geopandas.GeoDataFrame) – GeoDataFrame containing block geometries and Spacematrix morphotype 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 _get_strelka_morphotypes(blocks) GeoDataFrame[source]

Calculates Strelka morphotypes for the given blocks.

Parameters:

blocks (geopandas.GeoDataFrame) – GeoDataFrame containing block geometries and attributes.

Returns:

GeoDataFrame with Strelka morphotypes added.

Return type:

geopandas.GeoDataFrame

static _name_spacematrix_morphotypes(cluster) str[source]

Assigns names to Spacematrix morphotypes based on cluster data.

Parameters:

cluster (pandas.Series) – Series containing cluster data for each block.

Returns:

The name of the Spacematrix morphotype.

Return type:

str

_get_spacematrix_morphotypes(blocks) GeoDataFrame[source]

Calculates Spacematrix morphotypes for the given blocks using KMeans clustering.

Parameters:

blocks (geopandas.GeoDataFrame) – GeoDataFrame containing block geometries and attributes.

Returns:

GeoDataFrame with Spacematrix morphotypes and clusters added.

Return type:

geopandas.GeoDataFrame

calculate() GeoDataFrame[source]

Calculates Spacematrix and Strelka morphotypes for urban blocks.

Returns:

GeoDataFrame containing blocks with calculated Spacematrix and Strelka morphotypes.

Return type:

geopandas.GeoDataFrame

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

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