momepy.get_network_id

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

Snap each element (preferably building) to the closest street network segment, saves its id.

Adds network ID to elements.

Parameters
leftGeoDataFrame

GeoDataFrame containing objects to snap

rightGeoDataFrame

GeoDataFrame containing street network with unique network ID. If there is none, it could be generated by 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 id.

min_sizeint (default 100)

min_size should be a vaule 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.

Returns
elements_nIDSeries

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