momepy.SquareCompactness#

class momepy.SquareCompactness(gdf, areas=None, perimeters=None)[source]#

Calculates compactness index of each object in given GeoDataFrame.

\[\begin{equation*} \left(\frac{4 \sqrt{area}}{perimeter}\right) ^ 2 \end{equation*}\]

Adapted from [Feliciotti, 2018].

Parameters
gdfGeoDataFrame

GeoDataFrame containing objects

areasstr, list, np.array, pd.Series (default None)

the name of the dataframe column, np.array, or pd.Series where is stored area value. If set to None, function will calculate areas during the process without saving them separately.

perimetersstr, list, np.array, pd.Series (default None)

the name of the dataframe column, np.array, or pd.Series where is stored perimeter value. If set to None, function will calculate perimeters during the process without saving them separately.

Examples

>>> buildings_df['squ_comp'] = momepy.SquareCompactness(buildings_df).series
>>> buildings_df['squ_comp'][0]
0.6193872538650996
Attributes
seriesSeries

Series containing resulting values

gdfGeoDataFrame

original GeoDataFrame

areasSeries

Series containing used area values

perimetersSeries

Series containing used perimeter values

__init__(gdf, areas=None, perimeters=None)[source]#

Methods

__init__(gdf[, areas, perimeters])