{"id":70,"date":"2021-03-29T06:23:00","date_gmt":"2021-03-29T13:23:00","guid":{"rendered":"https:\/\/www.lunarip.com\/?p=70"},"modified":"2021-03-27T11:07:19","modified_gmt":"2021-03-27T18:07:19","slug":"network-maps-calculated-from-gps-coordinates","status":"publish","type":"post","link":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/","title":{"rendered":"Adding calculated distance to network maps calculated from GPS coordinates."},"content":{"rendered":"\n

Continuing the theme (part1<\/a>, part2<\/a>) of using GPS data to augment network graph data, this post will consider using the data for inclusion in the network graph but will also introduce taking the network graph and rendering this onto a geographical mapping visualization.<\/p>\n\n\n\n

NetworkX graph package<\/h2>\n\n\n\n

In these discussions I have been using the Python NetworkX<\/a> package to store a graph structure, nodes in this graph have city names as identifiers and edges created as a tuple or pair of city names. <\/p>\n\n\n\n

import networkx as nx\nimport matplotlib.pyplot as plt\nG = nx.Graph()\n\nCnames = ['Vancouver', 'Portland', 'San Francisco', 'Seattle', \n          'San Antonio', 'Dallas', 'Austin', 'Sevilla', \n          'Belfast', 'Sydney', 'Canberra', 'Tokyo']\nG.add_node(name)\nG.add_edge(name,'Dublin')<\/code><\/pre>\n\n\n\n

The NetworkX package allows for easy graph creation and manipulation, allows attributes to be added to the graph structure and then the package graph algorithms ( shortest path, cliquing, graph analysis) and also graph traversal, neighbor query and also graph drawing using standard plotting packages such as matplotlib<\/a>. <\/p>\n\n\n\n

plt.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
\"\"<\/figure><\/div>\n\n\n\n

Graph attributes, added and calculated<\/h2>\n\n\n\n

At this point, we now have a capability to generate a network graph that has named nodes and edges. The edges of the graph have a calculated distance derived from the GPS location of the nodes. An application of interest to me is calculating a idealized latency value for the network, i.e. what is the idealized one-way latency between location x and location y. <\/p>\n\n\n\n

One-way latency for model<\/h2>\n\n\n\n

For the global network model that we have incrementally built, we started with cities as nodes of the network, using the GPS coordinates of these cites we create graph edges between the cities and calculated the great circle distance between these cities. <\/p>\n\n\n\n

The next step in this model is to assume that a single fiber optic runs between these cities. This is unrealistic for geographical, technical, electro\/optical and political reasons but is adequate for the model that I am building. <\/p>\n\n\n\n

Light traveling in a fiber optic travels at a different speed than in free space. In free space light travels<\/a> at 299792458\u00a0m\/s (approximated as 3×10^5m\/s). In an optical fiber, light travels slower than in free space, approximately 35% slower based on the refractive index of the fiber optic between its core and its cladding. <\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

A fiber optic is composed of two different materials, the optic core and the optic cladding. As light leaves the optic core and enters the optic cladding it is refracted, at a certain angle (called the critical angle<\/a>) the refraction results in the light being totally reflected back into the optic core. This results as shown in the figure above have the light ray ‘bouncing’ along the fiber optic from one end to another. <\/p>\n\n\n\n

In the figure an angle \u03b8<\/em> is shown as the incident and relected angle, there is also a distance X marked which shows the linear distance along the fiber from one reflection point to another. While the light would traveling horizontally the distance of x when its in free space, because the light is inside the fiber optic it has to travel a longer distance donated as x\/sin(\u03b8<\/em>), so lets assume \u03b8<\/em> = 45 degrees, sin(45 deg) = 0.707 so the light in the fiber optic has to travel x\/0.707 which in this example is 1.41 times x, thus the earlier rule of thumb of light traveling 35% slower in an fiber optic. <\/p>\n\n\n\n

So this 35% figure we can say a modeled speed of light is 2.121X10^5 m\/s can be used. <\/p>\n\n\n\n

nodes = []\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'],\n                             Cities[name]).kilometers\n    G.edges['Dublin',name]['distance'] = round(distance,1)\n    G.edges['Dublin',name]['oneway-latency'] = \n                         distance * 2.121*10^^5<\/code><\/pre>\n\n\n\n

This latency calculation is assuming that the fiber optic is laid in a ‘straight line’ along the great circle between the two locations and does not include any optical regenerators, or intervening optical, or networking equipment.<\/p>\n","protected":false},"excerpt":{"rendered":"

Continuing the theme (part1, part2) of using GPS data to augment network graph data, this post will consider using the data for inclusion in the network graph but will also introduce taking the network graph and rendering this onto a geographical mapping visualization. NetworkX graph package In these discussions I have been using the Python […]<\/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":"\nAdding calculated distance to network maps calculated from GPS coordinates. - lunarip<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adding calculated distance to network maps calculated from GPS coordinates. - lunarip\" \/>\n<meta property=\"og:description\" content=\"Continuing the theme (part1, part2) of using GPS data to augment network graph data, this post will consider using the data for inclusion in the network graph but will also introduce taking the network graph and rendering this onto a geographical mapping visualization. NetworkX graph package In these discussions I have been using the Python […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/\" \/>\n<meta property=\"og:site_name\" content=\"lunarip\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-29T13:23:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-27T18:07:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.lunarip.com\/wp-content\/uploads\/2021\/03\/networkx_graph_draw.png\" \/>\n<meta name=\"author\" content=\"kevin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kevin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/\"},\"author\":{\"name\":\"kevin\",\"@id\":\"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b\"},\"headline\":\"Adding calculated distance to network maps calculated from GPS coordinates.\",\"datePublished\":\"2021-03-29T13:23:00+00:00\",\"dateModified\":\"2021-03-27T18:07:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/\"},\"wordCount\":584,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b\"},\"keywords\":[\"graph\",\"python\"],\"articleSection\":[\"Code\",\"Data Analysis\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/\",\"url\":\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/\",\"name\":\"Adding calculated distance to network maps calculated from GPS coordinates. - lunarip\",\"isPartOf\":{\"@id\":\"https:\/\/www.lunarip.com\/#website\"},\"datePublished\":\"2021-03-29T13:23:00+00:00\",\"dateModified\":\"2021-03-27T18:07:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.lunarip.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adding calculated distance to network maps calculated from GPS coordinates.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.lunarip.com\/#website\",\"url\":\"https:\/\/www.lunarip.com\/\",\"name\":\"lunarip\",\"description\":\"min(e|d) tailings of a neural net running on a 100w carbon system\",\"publisher\":{\"@id\":\"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.lunarip.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b\",\"name\":\"kevin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.lunarip.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.lunarip.com\/wp-content\/uploads\/2021\/03\/Sun_and_Moon_Nuremberg_chroniclex4.png\",\"contentUrl\":\"https:\/\/www.lunarip.com\/wp-content\/uploads\/2021\/03\/Sun_and_Moon_Nuremberg_chroniclex4.png\",\"width\":970,\"height\":238,\"caption\":\"kevin\"},\"logo\":{\"@id\":\"https:\/\/www.lunarip.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/www.lunarip.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Adding calculated distance to network maps calculated from GPS coordinates. - lunarip","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/","og_locale":"en_US","og_type":"article","og_title":"Adding calculated distance to network maps calculated from GPS coordinates. - lunarip","og_description":"Continuing the theme (part1, part2) of using GPS data to augment network graph data, this post will consider using the data for inclusion in the network graph but will also introduce taking the network graph and rendering this onto a geographical mapping visualization. NetworkX graph package In these discussions I have been using the Python […]","og_url":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/","og_site_name":"lunarip","article_published_time":"2021-03-29T13:23:00+00:00","article_modified_time":"2021-03-27T18:07:19+00:00","og_image":[{"url":"https:\/\/www.lunarip.com\/wp-content\/uploads\/2021\/03\/networkx_graph_draw.png"}],"author":"kevin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kevin","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#article","isPartOf":{"@id":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/"},"author":{"name":"kevin","@id":"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b"},"headline":"Adding calculated distance to network maps calculated from GPS coordinates.","datePublished":"2021-03-29T13:23:00+00:00","dateModified":"2021-03-27T18:07:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/"},"wordCount":584,"commentCount":0,"publisher":{"@id":"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b"},"keywords":["graph","python"],"articleSection":["Code","Data Analysis"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/","url":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/","name":"Adding calculated distance to network maps calculated from GPS coordinates. - lunarip","isPartOf":{"@id":"https:\/\/www.lunarip.com\/#website"},"datePublished":"2021-03-29T13:23:00+00:00","dateModified":"2021-03-27T18:07:19+00:00","breadcrumb":{"@id":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.lunarip.com\/index.php\/network-maps-calculated-from-gps-coordinates\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.lunarip.com\/"},{"@type":"ListItem","position":2,"name":"Adding calculated distance to network maps calculated from GPS coordinates."}]},{"@type":"WebSite","@id":"https:\/\/www.lunarip.com\/#website","url":"https:\/\/www.lunarip.com\/","name":"lunarip","description":"min(e|d) tailings of a neural net running on a 100w carbon system","publisher":{"@id":"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.lunarip.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.lunarip.com\/#\/schema\/person\/045a7b3f30cfedf6967672ed5c91bb5b","name":"kevin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.lunarip.com\/#\/schema\/person\/image\/","url":"https:\/\/www.lunarip.com\/wp-content\/uploads\/2021\/03\/Sun_and_Moon_Nuremberg_chroniclex4.png","contentUrl":"https:\/\/www.lunarip.com\/wp-content\/uploads\/2021\/03\/Sun_and_Moon_Nuremberg_chroniclex4.png","width":970,"height":238,"caption":"kevin"},"logo":{"@id":"https:\/\/www.lunarip.com\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/www.lunarip.com"]}]}},"_links":{"self":[{"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/posts\/70"}],"collection":[{"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":8,"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":123,"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/posts\/70\/revisions\/123"}],"wp:attachment":[{"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lunarip.com\/index.php\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}