I have a large data (10k rows) of locations (lat, lon) and I would like to compute a 10min-walk isochrone starting from each point with OSMnx. (I tried with openrouteservice but have some limitations). I tried with this example: https://github.com/gboeing/osmnx-examples/blob/v0.13.0/notebooks/13-isolines-isochrones.ipynb
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point, Polygon
import networkx as nx
import osmnx as ox
ox.config(log_console=True, use_cache=True)
def get_isochrone(lon, lat, walk_time=10, speed=4.5):
loc = (lat, lon)
G = ox.graph_from_point(loc, simplify=True, network_type='walk')
gdf_nodes = ox.graph_to_gdfs(G, edges=False)
x, y = gdf_nodes['geometry'].unary_union.centroid.xy
center_node = ox.get_nearest_node(G, (y[0], x[0]))
meters_per_minute = speed * 1000 / 60 #km per hour to m per minute
for u, v, k, data in G.edges(data=True, keys=True):
data['time'] = data['length'] / meters_per_minute
subgraph = nx.ego_graph(G, center_node, radius=walk_time, distance='time')
node_points = [Point(data['x'], data['y']) for node, data in subgraph.nodes(data=True)]
polys = gpd.GeoSeries(node_points).unary_union.convex_hull
return polys
and then apply it on my large scale pandas DataFrame:
df.apply(lambda x: get_isochrone(x.lon, x.lat), axis=1)
But took such amount of time. 100 rows is about 3 min running time. Is there any other methods, packges to achieve this goal ? With a reasonable running time ?
Last question, what are the limitations of OSMnx request, especially for large data ? Thank you