momepy.SquareCompactness#
- class momepy.SquareCompactness(gdf, areas=None, perimeters=None)[source]#
Calculates the compactness index of each object in a given GeoDataFrame.
\[\begin{equation*} \left(\frac{4 \sqrt{area}}{perimeter}\right) ^ 2 \end{equation*}\]Adapted from [Feliciotti, 2018].
- Parameters:
- gdfGeoDataFrame
A GeoDataFrame containing objects.
- areasstr, list, np.array, pd.Series (default None)
The name of the dataframe column,
np.array
, orpd.Series
where area values stored. If set toNone
, this function will calculate areas during the process without saving them separately.- areasstr, list, np.array, pd.Series (default None)
The name of the dataframe column,
np.array
, orpd.Series
where perimeter values stored. If set toNone
, this 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
A Series containing resulting values.
- gdfGeoDataFrame
The original GeoDataFrame.
- areasSeries
A Series containing used area values.
- perimetersSeries
A Series containing used perimeter values.
Methods
__init__
(gdf[, areas, perimeters])