The Fastest Way to the Coast
Find out the shortest possible path to get to a point of the US border from each capital of the conterminous US states.
Take the list of capitals.
In[1]:=
![Click for copyable input](assets.en/the-fastest-way-to-the-coast/In_88.png)
capitals =
EntityValue[
EntityClass["AdministrativeDivision", "ContinentalUSStates"],
"CapitalCity"]
Out[1]=
![](assets.en/the-fastest-way-to-the-coast/O_71.png)
Take the polygon of the US.
In[2]:=
![Click for copyable input](assets.en/the-fastest-way-to-the-coast/In_89.png)
us = EntityValue[Entity["Country", "UnitedStates"], "Polygon"]
Out[2]=
![](assets.en/the-fastest-way-to-the-coast/O_72.png)
Compute the closest point of the polygon boundary for each respective state capital.
In[3]:=
![Click for copyable input](assets.en/the-fastest-way-to-the-coast/In_90.png)
borderpoints = Flatten[Nearest[First[us], GeoPosition[capitals]]]
Out[3]=
![](assets.en/the-fastest-way-to-the-coast/O_73.png)
Draw all the geodesic paths.
In[4]:=
![Click for copyable input](assets.en/the-fastest-way-to-the-coast/In_91.png)
GeoGraphics[{us, Point[capitals], Red, Arrowheads[0.015],
Arrow /@ GeoPath /@ Thread[{capitals, borderpoints}]}]
Out[4]=
![](assets.en/the-fastest-way-to-the-coast/O_74.png)