momepy.get_network_id#

momepy.get_network_id(left, right, network_id, min_size=100, verbose=True)[source]#

Snap each element (preferably building) to the closest street network segment and save its ID. Also, adds network ID to elements.

Parameters
leftGeoDataFrame

A GeoDataFrame containing objects to snap.

rightGeoDataFrame

A GeoDataFrame containing a street network with unique network IDs. If there is none, it can be generated with momepy.unique_id().

network_idstr, list, np.array, pd.Series (default None)

The name of the streets dataframe column, np.array, or pd.Series with network unique IDs.

min_sizeint (default 100)

A minimum size should be a valuee such that if you build a box centered in each building centroid with edges of size 2*min_size, you know a priori that at least one segment is intersected with the box.

verbosebool (default True)

If True, shows progress bars in loops and indication of steps.

Returns
elements_nIDSeries

A Series containing network ID for elements.

Examples

>>> buildings_df['nID'] = momepy.get_network_id(buildings_df, streets_df, 'nID')
Generating centroids...
Generating rtree...
Snapping: 100%|██████████| 144/144 [00:00<00:00, 2718.98it/s]
>>> buildings_df['nID'][0]
1