除夕夜俄罗斯的明信片
这个例子是为了展示一个可能的场景,当从鸟瞰的角度看新年假期的通过。
我们将建立一个俄罗斯的地图,并应用几个主题装饰。
**你准备好了吗?**然后我们将安装一些我们需要的库。:
In [ ]:
]add GeoJSON
然后他们必须连接。:
In [ ]:
using GeoJSON, Dates, DelimitedFiles, LinearAlgebra
include("$(@__DIR__)/scripts/is_new_year_night.jl")
include("$(@__DIR__)/scripts/lonlat_2_xyz.jl")
include("$(@__DIR__)/scripts/draw_tree.jl")
include("$(@__DIR__)/scripts/draw_firework.jl")
让我们上传初始数据:地图和俄罗斯城市列表(我们创建了自己的地图,主要基于网站的材料<https://data.humdata.org />):
In [ ]:
# 阅读地图
fc = GeoJSON.read( "$(@__DIR__)/Russia_ADM1_0_1_gr.戈伊森" );
# 读取城市数据
города = readdlm("城市。csv档案源", ',', skipstart=1);
当空间地标建立时,我们将指示时间地标。:
In [ ]:
# 让我们决定是否要改变当前时间。
current_time_utc = now(Dates.UTC) + Hour(38)
# ... 或展示一时的画面
# current_time_utc = now(Dates.UTC)
现在我们的工程明信片已经准备好出版了.:
In [ ]:
plot(legend=false)
# 联邦的主体
for geom in fc.geometry
for subgeom in geom.coordinates
for ring in subgeom
x3d, y3d, z3d = lonlat_2_xyz(first.(ring), last.(ring))
plot!(x3d, y3d, z3d, color=rand([:skyblue, :lightseagreen, :darkcyan, :lightslateblue, :indigo]), linewidth=2, label=false)
end
end
end
# 本年度变化线
hour_utc = Dates.hour(current_time_utc) + Dates.minute(current_time_utc)/60 + Dates.second(current_time_utc)/3600
noon_longitude = (12 - hour_utc) * 15
midnight_longitude = noon_longitude + 180
if is_new_year_night(current_time_utc) && midnight_longitude > 30 && midnight_longitude < 190
line_lat_full = range(40, 90, 20)
for (lon_delta, lon_color) = zip([0,0.25,0.5,0.75], [:green3, :lightseagreen, :springgreen, :aquamarine])
line_lon_full = (midnight_longitude + lon_delta) .* ones(size(line_lat_full))
x3d_full, y3d_full, z3d_full = lonlat_2_xyz(line_lon_full, line_lat_full)
plot!(x3d_full, y3d_full, z3d_full, color=lon_color, linewidth=8, label=false, alpha=0.6)
end
end
# 树木及烟花
对于(lon,lat)在zip(Float64.(cities[:,3]),Float64.(城市[:,2]))
if lon < midnight_longitude
draw_tree(lon, lat, 0.3)
elseif lon < midnight_longitude + 15.0
# 敬礼!
draw_tree(lon+rand()-0.5, lat+rand()-0.5, 0.5)
draw_firework(lon+0.1rand(), lat+0.1rand())
else
draw_tree(lon, lat, 0.5)
end
end
# 工程明信片和普通明信片的主要区别在于图表上存在轴。
plot!(size=(1000, 600), camera=(-180, 25))
Out[0]:
我们希望这个例子能让你在新的一年里准确地传达你的心情。 新年快乐!