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.
GeoDataFrame containing objects to snap
GeoDataFrame containing street network with unique network ID.
If there is none, it could be generated by momepy.elements.unique_id()
.
the name of the streets dataframe column, np.array, or pd.Series with network unique id.
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.
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