momepy.Density#
- class momepy.Density(gdf, values, spatial_weights, unique_id, areas=None, verbose=True)[source]#
Calculate the gross density
\[\frac{\sum \text {values}}{\sum \text {areas}}\]Adapted from [Dibble et al., 2017].
- Parameters
- gdfGeoDataFrame
GeoDataFrame containing objects to analyse
- valuesstr, list, np.array, pd.Series
the name of the dataframe column,
np.array
, orpd.Series
where is stored character value.- spatial_weightslibpysal.weight
spatial weights matrix
- unique_idstr
name of the column with unique id used as
spatial_weights
index- areasstr, list, np.array, pd.Series (optional)
the name of the dataframe column,
np.array
, orpd.Series
where is stored area value. If None, gdf.geometry.area will be used.- verbosebool (default True)
if True, shows progress bars in loops and indication of steps
Examples
>>> tessellation_df['floor_area_dens'] = mm.Density(tessellation_df, ... 'floor_area', ... sw, ... 'uID').series
- Attributes
- seriesSeries
Series containing resulting values
- gdfGeoDataFrame
original GeoDataFrame
- valuesSeries
Series containing used values
- swlibpysal.weights
spatial weights matrix
- idSeries
Series containing used unique ID
- areasSeries
Series containing used area values
Methods
__init__
(gdf, values, spatial_weights, unique_id)