momepy.
AverageCharacter
Calculates the average of a character within a set neighbourhood defined in spatial_weights
spatial_weights
Average value of the character within a set neighbourhood defined in spatial_weights. Can be set to mean, median or mode. mean is defined as:
mean
median
mode
Adapted from [HBP17].
GeoDataFrame containing morphological tessellation
the name of the dataframe column, np.array, or pd.Series where is stored character value.
np.array
pd.Series
name of the column with unique id used as spatial_weights index.
spatial weights matrix
Percentiles over which to compute the range. Each must be between 0 and 100, inclusive. The order of the elements is not important.
mode of average calculation. Can be set to all, mean, median or mode or list of any of the options.
if True, shows progress bars in loops and indication of steps
Examples
>>> sw = libpysal.weights.DistanceBand.from_dataframe(tessellation, ... threshold=100, ... silence_warnings=True, ... ids='uID') >>> tessellation['mean_area'] = momepy.AverageCharacter(tessellation, ... values='area', ... spatial_weights=sw, ... unique_id='uID').mean 100%|██████████| 144/144 [00:00<00:00, 1433.32it/s] >>> tessellation.mean_area[0] 4823.1334436678835
Series containing resulting mean values
Series containing resulting median values
Series containing resulting mode values
original GeoDataFrame
Series containing used values
Series containing used unique ID
range
__init__
Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(gdf, values, spatial_weights, unique_id)
Initialize self.