momepy.AverageCharacter

class momepy.AverageCharacter(gdf, values, spatial_weights, unique_id, rng=None, mode='mean')[source]

Calculates the average of a character within k steps of morphological tessellation

Average value of the character within k topological steps defined in spatial_weights. Can be set to mean, median or mode. mean is defined as:

\[\frac{1}{n}\left(\sum_{i=1}^{n} value_{i}\right)\]
Parameters
gdfGeoDataFrame

GeoDataFrame containing morphological tessellation

valuesstr, list, np.array, pd.Series

the name of the dataframe column, np.array, or pd.Series where is stored character value.

unique_idstr

name of the column with unique id used as spatial_weights index.

spatial_weightslibpysal.weights

spatial weights matrix

rngTwo-element sequence containing floats in range of [0,100], optional

Percentiles over which to compute the range. Each must be between 0 and 100, inclusive. The order of the elements is not important.

modestr (default ‘mean’)

mode of average calculation. Can be set to mean, median or mode.

References

Hausleitner B and Berghauser Pont M (2017) Development of a configurational typology for micro-businesses integrating geometric and configurational variables. [adapted]

Examples

>>> sw = libpysal.weights.DistanceBand.from_dataframe(tessellation, threshold=100, silence_warnings=True, ids='uID')
>>> tessellation['mesh_100'] = momepy.AverageCharacter(tessellation, values='area', spatial_weights=sw, unique_id='uID').series
100%|██████████| 144/144 [00:00<00:00, 1433.32it/s]
>>> tessellation.mesh_100[0]
4823.1334436678835
Attributes
seriesSeries

Series containing resulting values

gdfGeoDataFrame

original GeoDataFrame

valuesGeoDataFrame

Series containing used values

swlibpysal.weights

spatial weights matrix

idSeries

Series containing used unique ID

rngtuple

range

modestr

mode

__init__(self, gdf, values, spatial_weights, unique_id, rng=None, mode='mean')[source]

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

Methods

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

Initialize self.