momepy.WeightedCharacter¶
-
class
momepy.
WeightedCharacter
(gdf, values, spatial_weights, unique_id, areas=None, verbose=True)[source]¶ Calculates the weighted character
Character weighted by the area of the objects within neighbors defined in
spatial_weights
.\[\frac{\sum_{i=1}^{n} {character_{i} * area_{i}}}{\sum_{i=1}^{n} area_{i}}\]Adapted from [DPR+17].
- Parameters
- gdfGeoDataFrame
GeoDataFrame containing objects to analyse
- valuesstr, list, np.array, pd.Series
the name of the gdf dataframe column,
np.array
, orpd.Series
where is stored character to be weighted- spatial_weightslibpysal.weights
spatial weights matrix - If None, Queen contiguity matrix of set order will be calculated based on left.
- unique_idstr
name of the column with unique id used as
spatial_weights
index.- areasstr, list, np.array, pd.Series (default None)
the name of the left dataframe column,
np.array
, orpd.Series
where is stored area value- verbosebool (default True)
if True, shows progress bars in loops and indication of steps
Examples
>>> sw = libpysal.weights.DistanceBand.from_dataframe(tessellation_df, ... threshold=100, ... silence_warnings=True) >>> buildings_df['w_height_100'] = momepy.WeightedCharacter(buildings_df, ... values='height', ... spatial_weights=sw, ... unique_id='uID').series 100%|██████████| 144/144 [00:00<00:00, 361.60it/s]
- Attributes
- seriesSeries
Series containing resulting values
- gdfGeoDataFrame
original GeoDataFrame
- valuesGeoDataFrame
Series containing used values
- areasGeoDataFrame
Series containing used areas
- swlibpysal.weights
spatial weights matrix
- idSeries
Series containing used unique ID
-
__init__
(gdf, values, spatial_weights, unique_id, areas=None, verbose=True)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(gdf, values, spatial_weights, unique_id)Initialize self.