# momepy.preprocess¶

momepy.preprocess(buildings, size=30, compactness=True, islands=True)[source]

Preprocesses building geometry to eliminate additional structures being single features.

Certain data providers (e.g. Ordnance Survey in GB) do not provide building geometry as one feature, but divided into different features depending their level (if they are on ground floor or not - passages, overhangs). Ideally, these features should share one building ID on which they could be dissolved. If this is not the case, series of steps needs to be done to minimize errors in morphological analysis.

This script attempts to preprocess such geometry based on several condidions: If feature area is smaller than set size it will be a) deleted if it does not touch any other feature; b) will be joined to feature with which it shares the longest boundary. If feature is fully within other feature, these will be joined. If feature’s circular compactness (momepy.circular_compactness()) is < 0.2, it will be joined to feature with which it shares the longest boundary. Function does two loops through.

Parameters
buildingsgeopandas.GeoDataFrame

geopandas.GeoDataFrame containing building layer

sizefloat (default 30)

maximum area of feature to be considered as additional structure. Set to None if not wanted.

compactnessbool (default True)

if True, function will resolve additional structures identified based on their circular compactness.

islandsbool (default True)

if True, function will resolve additional structures which are fully within other structures (share 100% of exterior boundary).

Returns
GeoDataFrame

GeoDataFrame containing preprocessed geometry