A postcard with a view of Russia on New Year's Eve
The example is intended to demonstrate a possible scenario for the New Year holidays when observing Russia from space.
We will build a map and apply some themed decorations.
** Are you ready?** Then we'll install some of the libraries we need.:
Pkg.add("GeoJSON")
Then they must be connected.:
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");
Let's download the initial data: maps and a list of Russian cities (we have created our own map, mainly based on the materials of the website <https://data.humdata.org />):
# Reading a map with subject boundaries
fc = GeoJSON.read( "$(@__DIR__)/Россия_ADM1_0_1_гр.geojson" );
# Reading city data
города = readdlm("$(@__DIR__)/города.csv", ',', skipstart=1);
When the spatial landmarks are established, we will indicate the time landmarks and our engineering postcard will be ready for publication.:
# @markdown To build a map based on local time?
Время = "местное текущее время" # @param ["local current time","select time zone"]
# @markdown Or set the desired time zone relative to Moscow
Часовой_пояс = 2 # @param {type:"slider",min:-2,max:10,step:0.25}
if Время == "местное текущее время"
current_time = now(Dates.UTC)
utc_hours = Dates.hour(current_time) + Dates.minute(current_time) / 60
moscow_hour = utc_hours + 3
midnight_lon = 180.0 - moscow_hour * 15.0
midnight_lon = mod(midnight_lon + 180, 360)
else
utc_hours = 9.5 - Часовой_пояс
# The current year change line
noon_lon = (12 - utc_hours) * 15
midnight_lon = mod(noon_lon + 180, 360) - 180
end
plot(legend=false, bg_color=:white, bg_inside=:white)
# Subjects of the Federation
for geom in fc.geometry
for subgeom in geom.coordinates
for ring in subgeom
if length(last.(ring)) < 10 continue; end;
x3d, y3d, z3d = lonlat_2_xyz(first.(ring), last.(ring))
plot!(x3d, y3d, z3d, color=rand([:skyblue, :lightseagreen, :darkcyan, :lightslateblue, :indigo]), linewidth=4, label=false)
end
end
end
# if is_new_year_night(current_time) && midnight_lon > 30 && midnight_lon < 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_lon + 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
# Trees and fireworks
for (lon,lat) in zip(Float64.(города[:, 3]), Float64.(города[:, 2]))
if lon < midnight_lon
draw_tree(lon, lat, 0.3)
elseif lon < midnight_lon + 15.0
# A salute!
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
# The main difference between an engineering postcard and a regular one is the presence of axes on the graph.
plot!(size=(1200, 700), camera=(-180, 25))
To download an image, click <svg viewBox="0 0 1000 1000" class="icon" height="1em" width="1em"><path d="m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z M400 150H-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28L-31-94c-6-15-23-28-40- 28h-120C-55 0-100-45-100-100v-450c0-55 45-100 100- 100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250- 250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35- 35z" transform="matrix(1 0 0 -1 0 850)"></ path></svg> in the upper-right corner of the graph.
We hope that this example will allow you to accurately convey your mood during this New Year's time. Happy New Year!