diff --git a/Shortest route.ipynb b/Shortest route.ipynb new file mode 100644 index 0000000..3bc6b58 --- /dev/null +++ b/Shortest route.ipynb @@ -0,0 +1,303 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "id": "206f6227", + "metadata": {}, + "outputs": [], + "source": [ + "import osmnx as ox\n", + "import networkx as nx\n", + "ox.settings.log_console=True\n", + "ox.settings.use_cache=True" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "dd1fb1b1", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\saisu\\AppData\\Local\\Temp\\ipykernel_25128\\3614091016.py:24: UserWarning: The `folium` module has been deprecated and will be removed in a future release. You can generate and explore interactive web maps of graph nodes, edges, and/or routes automatically using GeoPandas.GeoDataFrame.explore instead, for example like: `ox.graph_to_gdfs(G, nodes=False).explore()`. See the OSMnx examples gallery for complete details and demonstrations.\n", + " shortest_route_map = ox.plot_route_folium(graph, shortest_route)\n" + ] + }, + { + "data": { + "text/html": [ + "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "start_latlng = (20.342942002308178, 85.80738916756827)\n", + "end_latlng = (20.332539959730706, 85.82142248452695)\n", + "place = 'Bhubaneswar, Odisha, India'\n", + "mode = 'walk'\n", + "optimizer = 'time' \n", + "orig_node = ox.distance.nearest_nodes(graph, start_latlng[1],start_latlng[0])\n", + "dest_node = ox.distance.nearest_nodes(graph, end_latlng[1],end_latlng[0])\n", + "shortest_route = nx.shortest_path(graph,orig_node,dest_node,weight=optimizer)\n", + "shortest_route_map = ox.plot_route_folium(graph, shortest_route)\n", + "shortest_route_map" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}