def match_stops_to_nodes(gtfs, walk_network):
network_nodes = walk_network.nodes(data="<STR_LIT:true>")<EOL>stop_Is = set(gtfs.get_straight_line_transfer_distances()['<STR_LIT>'])<EOL>stops_df = gtfs.stops()<EOL>geo_index = GeoGridIndex(precision=<NUM_LIT:6>)<EOL>for net_node, data in network_nodes:<EOL><INDENT>geo_index.add_point(GeoPoint(data['<STR_LIT>'], data['<STR_LIT>'], ref=net_node))<EOL><DEDENT>stop_I_to_node = {}<EOL>stop_I_to_dist = {}<EOL>for stop_I in stop_Is:<EOL><INDENT>stop_lat = float(stops_df[stops_df.stop_I == stop_I].lat)<EOL>stop_lon = float(stops_df[stops_df.stop_I == stop_I].lon)<EOL>geo_point = GeoPoint(stop_lat, stop_lon)<EOL>min_dist = float('<STR_LIT>')<EOL>min_dist_node = None<EOL>search_distances_m = [<NUM_LIT>, <NUM_LIT>]<EOL>for search_distance_m in search_distances_m:<EOL><INDENT>for point, distance in geo_index.get_nearest_points(geo_point, search_distance_m, "<STR_LIT>"):<EOL><INDENT>if distance < min_dist:<EOL><INDENT>min_dist = distance * <NUM_LIT:1000><EOL>min_dist_node = point.ref<EOL><DEDENT><DEDENT>if min_dist_node is not None:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if min_dist_node is None:<EOL><INDENT>warn("<STR_LIT>" + str(stops_df[stops_df.stop_I == stop_I]))<EOL><DEDENT>stop_I_to_node[stop_I] = min_dist_node<EOL>stop_I_to_dist[stop_I] = min_dist<EOL><DEDENT>return stop_I_to_node, stop_I_to_dist<EOL>
Parameters
----------
gtfs : a GTFS object
walk_network : networkx.Graph

Returns
-------
stop_I_to_node: dict
    maps stop_I to closest walk_network node
stop_I_to_dist: dict
    maps stop_I to the distance to the closest walk_network node