momepy.Density

class momepy.Density(gdf, values, spatial_weights, unique_id, areas=None)[source]

Calculate the gross density

\[\frac{\sum \text {values}}{\sum \text {areas}}\]

Adapted from [DPR+17].

Parameters
gdfGeoDataFrame

GeoDataFrame containing objects to analyse

valuesstr, list, np.array, pd.Series

the name of the dataframe column, np.array, or pd.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, or pd.Series where is stored area value. If None, gdf.geometry.area will be used.

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

__init__(self, gdf, values, spatial_weights, unique_id, areas=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, gdf, values, spatial_weights, …)

Initialize self.