I have 20 million (latitude, longitude) points from all over the US. I want to find the nearest road to each point and extract the speed limit and road type. I was able to do this with the openstreetmap Overpass API Osmnx.
I used the following code.
network = osmnx.graph_from_point((lat, long), dist=distance)
nearest_edge = osmnx.nearest_edges(network, long, lat, return_dist=False)[:2]graph_edges_dictionary = network.edges.keys()._mapping.data()._adjdict
nearest_edge_info = graph_edges_dictionary[nearest_edge[0]][nearest_edge[1]][0]highway = nearest_edge_info.get(‘highway’, None)
maxspeed = nearest_edge_info.get(‘maxspeed’, None)
The problem was that there seems to be a rate limit, and they recommend staying under 10,000 requests per day. I got blocked from running the osmnx.graph_from_point function after a while. There’s no way I can get through all this data in a reasonable time frame staying at this limit as that would take years. How can I efficiently query this data? Do I have to set up my own server? How would I go about that?
2 posts - 2 participants
Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/how-can-i-efficiently-query-the-highway-tag-and-the-max-speed-tag-for-the-nearest-road-to-20-million-lat-long-points/103972