|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "from geopy.geocoders import Nominatim, ArcGIS\n", |
| 10 | + "from geopy import distance\n", |
| 11 | + "import folium\n", |
| 12 | + "geodecoder = Nominatim(user_agent=\"python\")\n", |
| 13 | + "\n", |
| 14 | + "location1 = input(\"\\nEnter your starting location : \")\n", |
| 15 | + "location2 = input(\"Enter your Destination : \")\n", |
| 16 | + "\n", |
| 17 | + "coordinates1 = geodecoder.geocode(location1)\n", |
| 18 | + "coordinates2 = geodecoder.geocode(location2)\n", |
| 19 | + "\n", |
| 20 | + "a = ArcGIS()\n", |
| 21 | + "loca1 = a.geocode(location1)\n", |
| 22 | + "loca1lat = loca1.latitude\n", |
| 23 | + "loca1lon = loca1.longitude\n", |
| 24 | + "loca2 = a.geocode(location2)\n", |
| 25 | + "loca2lat = loca2.latitude\n", |
| 26 | + "loca2lon = loca2.longitude\n", |
| 27 | + "map = folium.Map(location=[loca1lat,loca1lon],zoom_start=4)\n", |
| 28 | + "locationcap1 = location1.capitalize()\n", |
| 29 | + "locationcap2 = location2.capitalize()\n", |
| 30 | + "\n", |
| 31 | + "startingLoc = (loca1lat, loca1lon)\n", |
| 32 | + "destination = (loca2lat, loca2lon)\n", |
| 33 | + "\n", |
| 34 | + "diststr = str(distance.distance(startingLoc,destination)).split(\".\",2)[0]\n", |
| 35 | + "\n", |
| 36 | + "\n", |
| 37 | + "print(f\"Aerial Distance between your location is {diststr} km (approx..)\")\n", |
| 38 | + "map.add_child(folium.Marker(location=[loca2lat,loca2lon],popup=locationcap2,icon=folium.Icon(color=\"red\")))\n", |
| 39 | + "map.add_child(folium.Marker(location=[loca1lat,loca1lon],popup=locationcap1,icon=folium.Icon(color=\"red\")))" |
| 40 | + ] |
| 41 | + } |
| 42 | + ], |
| 43 | + "metadata": { |
| 44 | + "interpreter": { |
| 45 | + "hash": "ab3298061894ea8e9f63d33ee7154e99389b529bdefd6424b2d3fed3fb422773" |
| 46 | + }, |
| 47 | + "kernelspec": { |
| 48 | + "display_name": "Python 3.9.7 64-bit", |
| 49 | + "language": "python", |
| 50 | + "name": "python3" |
| 51 | + }, |
| 52 | + "language_info": { |
| 53 | + "codemirror_mode": { |
| 54 | + "name": "ipython", |
| 55 | + "version": 3 |
| 56 | + }, |
| 57 | + "file_extension": ".py", |
| 58 | + "mimetype": "text/x-python", |
| 59 | + "name": "python", |
| 60 | + "nbconvert_exporter": "python", |
| 61 | + "pygments_lexer": "ipython3", |
| 62 | + "version": "3.9.7" |
| 63 | + }, |
| 64 | + "orig_nbformat": 4 |
| 65 | + }, |
| 66 | + "nbformat": 4, |
| 67 | + "nbformat_minor": 2 |
| 68 | +} |
0 commit comments