Travel All Capitals of the Conterminous US States
Obtain the list of the capitals of the 48 conterminous US states.
In[1]:=
capitals =
EntityValue[
EntityClass["AdministrativeDivision", "ContinentalUSStates"],
"CapitalCity"]
Out[1]=
Download their GeoPosition coordinates.
In[2]:=
GeoPosition[capitals]
Out[2]=
Compute the order in which the cities should be visited to minimize the total geodetic distance.
In[3]:=
GeoPosition[capitals];
{d, perm} = FindShortestTour[%]
Out[3]=
Represent that path on a map.
In[4]:=
GeoGraphics[{GeoPath[capitals[[perm]]], Red, PointSize[Medium],
Point[capitals]}]
Out[4]=
Now compute travel directions to drive through the same cities in the same order.
In[5]:=
td = TravelDirections[capitals[[perm]]];
Represent the corresponding path on a map.
In[6]:=
GeoGraphics[{td["TravelPath"], Red, PointSize[Medium],
Point[capitals]}]
Out[6]=
The total distance to drive is shown.
In[7]:=
td["TravelDistance"]
Out[7]=
Compare with the geodetic distance.
In[8]:=
d
Out[8]=