{"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 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 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 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 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\nNetworkX graph package<\/h2>\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
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
One-way latency for model<\/h2>\n\n\n\n
<\/figure>\n\n\n\n