MATLAB Answers

## Undirected graph network with latitude and longitude as node

Asked by Poulomi Ganguli

### Poulomi Ganguli (view profile)

on 20 Jul 2019
Latest activity Commented on by Steven Lord

### Steven Lord (view profile)

on 21 Jul 2019
Accepted Answer by Steven Lord

### Steven Lord (view profile)

Is there any way to plot graph structure describing nodes, edges and links but with latitude and logitude as the co-ordinates using MATLAB, like the one describe here:

#### 0 Comments

Sign in to comment.

## 2 Answers

### Steven Lord (view profile)

Answer by Steven Lord

### Steven Lord (view profile)

on 21 Jul 2019
Accepted Answer

See this post on Loren Shure's blog for an example that plots US states (as polyshape objects) along with their centroids (as nodes of a graph, with two centroids connected by an edge if the states they represent share a border.) The latitude and longitude data comes from a shapefile included in Mapping Toolbox.
If you had coordinates for the capitals of those states, you could store that data in the Nodes table of the graph as custom attributes and use those as the X and Y data (and Z data, I suppose, though that may not be so useful) when you call plot on the graph.

Poulomi Ganguli

### Poulomi Ganguli (view profile)

on 21 Jul 2019
Yes, I have the co-ordinates of the nodes data in the form of latitude and longitude and same for the target nodes. My query is the example shows using polyshape function for US states, assuming they are contained in a polygon, will this also work for arbitrary source and target latitude-longitude?
Steven Lord

### Steven Lord (view profile)

on 21 Jul 2019
In that example, the polyshape objects representing the state boundaries and the graph object representing the state centroids are independent MATLAB objects. The only relation between them is that their coordinates are both latitude and longitude values so they represent areas in the same section of the map.
If you wanted to create a graph that represents the board for the game Ticket to Ride you could do so. I've done this. [You'd want to use release R2018a or later for this, as the board is a multigraph.]

Sign in to comment.

### Sulaymon Eshkabilov (view profile)

Answer by Sulaymon Eshkabilov

### Sulaymon Eshkabilov (view profile)

on 20 Jul 2019

You can employ graph() or digraph() plot tools of MATLAB.

Poulomi Ganguli

### Poulomi Ganguli (view profile)

on 20 Jul 2019
These functions only works for displaying graph structure over cartesian co-ordinates & not over showing links and edges over a shapefile.

Sign in to comment.