{"id":86,"date":"2021-03-27T15:16:00","date_gmt":"2021-03-27T22:16:00","guid":{"rendered":"https:\/\/www.lunarip.com\/?p=86"},"modified":"2021-03-28T13:33:02","modified_gmt":"2021-03-28T20:33:02","slug":"calculating-the-distance-between-2-gps-cordinates-follow-on","status":"publish","type":"post","link":"https:\/\/www.lunarip.com\/index.php\/calculating-the-distance-between-2-gps-cordinates-follow-on\/","title":{"rendered":"Calculating the distance between 2 GPS Cordinates – Follow on"},"content":{"rendered":"\n
In a previous post<\/a>, I discussed calculating distances based on GPS coordinates, subsequently I came across a good python library that offers this functionality as well as a lot more. I decided that anybody that is interested in the distance calculation via GPS coordinates will probably appreciate everything else that the GeoPy library<\/a> has to offer. <\/p>\n\n\n\n In addition to the distance calculation, GeoPy offers a client functionality to access several popular geocoding web servers. <\/p>\n\n\n\n From the Readme file of the package’s GitHub site: <\/p>\n\n\n\n geopy makes it easy for Python developers to locate the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources.<\/em><\/p>\n\n\n\n geopy includes geocoder classes for the OpenStreetMap Nominatim<\/a>, Google Geocoding API (V3)<\/a>, and many other geocoding services.<\/em><\/p>\n\n\n\n Here is my previous example coded with the GeoPY library<\/p>\n\n\n\n A complete example is provided in the following GitHub page<\/a><\/p>\n\n\n\n The GeoPy library is well worth reviewing as it also have a litany of functions which I did not cover here including:<\/p>\n\n\n\n Geocoding is provided by a number of different services, which are not affiliated with geopy. These services provide APIs, which anyone could implement, and geopy is a library which provides these implementations for many different services in a single package.<\/p>\n","protected":false},"excerpt":{"rendered":" In a previous post, I discussed calculating distances based on GPS coordinates, subsequently I came across a good python library that offers this functionality as well as a lot more. I decided that anybody that is interested in the distance calculation via GPS coordinates will probably appreciate everything else that the GeoPy library has to […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"hide_page_title":"","_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":""},"categories":[12,13],"tags":[15,14],"yoast_head":"\nfrom geopy.distance import great_circle\nDublin = (53.35, -6.27)\nSanFrancisco=(37.78, -122.42)\n\ngreat_cicle_dis = great_circle(Dublin, San Francisco).kilometers\ngeodesic_dis = geodesic(Dublin, San Francisco).kilometers\n\nCities = { 'Vancouver':(49.25,-123.1),\n 'Portland':(45.52,-122.68),\n 'San Francisco':(37.78, -122.42),\n 'Seattle':(47.62, -122.33),\n 'San Antonio':(29.42, -98.5),\n 'Dallas':(32.78,-96.8),\n 'Austin':(30.25,-97.75),\n 'Dublin':(53.35, -6.27),\n 'Sevilla':(37.38, -5.98),\n 'Belfast':(54.6,-5.93),\n 'Sydney':(-33.87, 151.22),\n 'Canberra':(-35.3, 149.12),\n 'Tokyo':(35.68, 139.7)}\n\nimport networkx as nx\nimport matplotlib.pyplot as plt\nG = nx.Graph()\nCnames = ['Vancouver', 'Portland', 'San Francisco', 'Seattle', \n 'San Antonio', 'Dallas', 'Austin', 'Sevilla', \n 'Belfast', 'Sydney', 'Canberra', 'Tokyo']\nnodes = []\nfor name in Cnames:\n nodes.append(name)\n G.add_node(name)\n G.add_edge(name,'Dublin')\n distance = great_circle(Cities['Dublin'],Cities[name]).kilometers\n G.edges['Dublin',name]['distance'] = round(distance,1)\nplt.figure(figsize=(8, 8))\npos = nx.spring_layout(G)\nnx.draw(G,nodelist=nodes,with_labels=True,pos=pos)\n_ = nx.draw_networkx_edge_labels(G,pos=pos)<\/code><\/pre>\n\n\n\n