Le chemin le plus rapide vers la côte
Trouvez le chemin le plus court possible pour atteindre un point de la frontière américaine à partir de chaque capitale des États américains limitrophes.
Prenez la liste des capitales.
In[1]:=
![Click for copyable input](assets.fr/the-fastest-way-to-the-coast/In_88.png)
capitals =
EntityValue[
EntityClass["AdministrativeDivision", "ContinentalUSStates"],
"CapitalCity"]
Out[1]=
![](assets.fr/the-fastest-way-to-the-coast/O_71.png)
Prenez le polygone des États-Unis.
In[2]:=
![Click for copyable input](assets.fr/the-fastest-way-to-the-coast/In_89.png)
us = EntityValue[Entity["Country", "UnitedStates"], "Polygon"]
Out[2]=
![](assets.fr/the-fastest-way-to-the-coast/O_72.png)
Calculez le point le plus proche de la limite du polygone pour chaque capitale d'État.
In[3]:=
![Click for copyable input](assets.fr/the-fastest-way-to-the-coast/In_90.png)
borderpoints = Flatten[Nearest[First[us], GeoPosition[capitals]]]
Out[3]=
![](assets.fr/the-fastest-way-to-the-coast/O_73.png)
Dessinez tous les chemins géodésiques.
In[4]:=
![Click for copyable input](assets.fr/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.fr/the-fastest-way-to-the-coast/O_74.png)