开车到香槟
画出从美国 300 个最大的城市到沃尔夫勒姆研究公司在伊利诺伊州香槟市的总部的道路.
In[1]:=
champaign = Entity["City", {"Champaign", "Illinois", "UnitedStates"}]
Out[1]=
In[2]:=
us = Entity["Country", "UnitedStates"]
Out[2]=
这是美国最大城市的列表.
In[3]:=
Length[cities = CityData[{Large, "UnitedStates"}]]
Out[3]=
计算到香槟的旅行路径.
In[4]:=
roads = Quiet@TravelDirections[{#, champaign}, "TravelPath"] & /@
cities;
消去几个失败的例子,例如从檀香山到香槟.
In[5]:=
Length[roads = Cases[roads, _GeoPath]]
Out[5]=
绘制地图.
In[6]:=
GeoGraphics[{
GeoStyling[White], Polygon[us],
Red, Opacity[.1], roads,
Black, Opacity[0.6], Point[cities],
Blue, Opacity[1], PointSize[Large], Point[champaign]
}, GeoBackground -> LightBlue, ImageSize -> 600,
GeoRange -> us] // Rasterize
Out[6]=