momepy.courtyard_index#

momepy.courtyard_index(geometry, courtyard_area=None)[source]#

Calculates the courtyard index of each object given its geometry.

\[\textit{area of courtyards} \over \textit{total area}\]

Adapted from [Schirmer and Axhausen, 2015].

Parameters:
geometryGeoDataFrame | GeoSeries

A GeoDataFrame or GeoSeries containing polygons to analyse.

courtyard_areaNDArray[np.float64] | Series | None, optional

array of courtyard areas. If None, it will be calculated, by default None

Returns:
Series

Examples

>>> path = momepy.datasets.get_path("bubenec")
>>> buildings = geopandas.read_file(path, layer="buildings")
>>> ci = momepy.courtyard_index(buildings)
>>> ci
0      0.0
1      0.0
2      0.0
3      0.0
4      0.0
    ...
139    0.0
140    0.0
141    0.0
142    0.0
143    0.0
Length: 144, dtype: float64
>>> ci.max()
np.float64(0.16605915738643523)

If you know the courtyard area, you can pass it to skip the computation step.

>>> courtyard_area = momepy.courtyard_area(buildings)
>>> momepy.courtyard_index(buildings, courtyard_area=courtyard_area)
0      0.0
1      0.0
2      0.0
3      0.0
4      0.0
    ...
139    0.0
140    0.0
141    0.0
142    0.0
143    0.0
Length: 144, dtype: float64