Самый быстрый маршрут до побережья
Найдите самый короткий возможный маршрут до точки на границе США от столицы каждого граничащего штата.
Получите список столиц.
In[1]:=
![Click for copyable input](assets.ru/the-fastest-way-to-the-coast/In_88.png)
capitals =
EntityValue[
EntityClass["AdministrativeDivision", "ContinentalUSStates"],
"CapitalCity"]
Out[1]=
![](assets.ru/the-fastest-way-to-the-coast/O_71.png)
Получите полигон США.
In[2]:=
![Click for copyable input](assets.ru/the-fastest-way-to-the-coast/In_89.png)
us = EntityValue[Entity["Country", "UnitedStates"], "Polygon"]
Out[2]=
![](assets.ru/the-fastest-way-to-the-coast/O_72.png)
Рассчитайте ближайшую точку границы полигона для каждой соответствующей столицы штата.
In[3]:=
![Click for copyable input](assets.ru/the-fastest-way-to-the-coast/In_90.png)
borderpoints = Flatten[Nearest[First[us], GeoPosition[capitals]]]
Out[3]=
![](assets.ru/the-fastest-way-to-the-coast/O_73.png)
Начертите все геодезические маршруты.
In[4]:=
![Click for copyable input](assets.ru/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.ru/the-fastest-way-to-the-coast/O_74.png)