momepy.
get_network_id
Snap each element (preferably building) to the closest street network segment, saves its id.
Adds network ID to elements.
GeoDataFrame containing objects to snap
GeoDataFrame containing street network with unique network ID. If there is none, it could be generated by momepy.unique_id().
momepy.unique_id()
the name of the streets dataframe column, np.array, or pd.Series with network unique id.
np.array
pd.Series
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.
2*min_size
if True, shows progress bars in loops and indication of steps
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