# How best to convert a (lat,long) network into a "line diagram" in MATLAB?

2 views (last 30 days)
Darcy Cordell on 5 Jul 2023
Answered: Deep on 8 Jul 2023
I have a transmission network with substations in (lat,long) coordinates connected by transmission line segments. I want to plot this in a pseudo-map view where the relationships between substations and transmission lines is roughly maintained, but the distances are not to scale so that you can actually see all the detail.
For example, if I have two substations separated by 100 km and two other substations separated by 2 km, I want to be able to plot them in "map view" while still being able to clearly see the details of each substation. Basically, I just want to make a single line diagram given my network (lat, long) values to conver from something like this:
to this:
Any help is appreciated.
Note that I do not have access and have never used SimuLink.

Deep on 8 Jul 2023
If you only need an unscaled version of your graph, it is simply possible to plot the graph in MATLAB with unweighted edges, and it can look like the following. The distances plotted here are just strings labels, the graph is basically plotted without notion of edge-distance. It should be simplest for you to populate the data as a list of lines/edges (or an edge-list). I hope the following code is self explanatory:
labelarray = {'Station1', 'Station2', 'Station3', 'Station4', 'Station5'};
% example edge list
% replace this with your real data.
% each number corresponds to the names above.
edges = [1 2; 1 3; 2 3; 2 4; 3 4; 4 5];
edgeLabels = {'100 km', '50 km', '80 km', '6 km', '100 km', '2 km'}; % replace with your desired labels
% create graph
G = graph(edges(:,1), edges(:,2));
% plot the graph
p = plot(G);
p.NodeLabel = labelarray;
highlight(p, [1 3], [2 4], 'LineStyle', '--'); % bonus: you can change lines to dashed for specific edges
labeledge(p, 1:numedges(G), edgeLabels);
You can find more about graph and plot in the official MATLAB documentation: