Visualization

This section will illustrate how to use the APIs for visualizing the data. At the moment it supports all countries affected by the Western-North Pacific (WNP) cyclones. These are:

Country ISO3
Brunie BRN
China CHN
Japan JPN
Cambodia KHM
South Korea KOR
Laos LAO
Myanmar MMR
Malaysia MYS
Philippines PHL
North Korea PRK
Russia RUS
Thailand THA
Taiwand TWN
Vietnam VNM

The countries' ISO3 are used in all APIs of Bagyo.jl for representing the country.

First Plot

To start with the base plot–a plot of the WNP region and the countries surrounding it–with emphasis on a particular country and its climate region of interest, is done as follows:

using Bagyo
f0, a0 = plot(PHL(), :stere);
f0

The plot above gives emphasis on the Philippine Area of Responsibility (PAR).

Adding Best Tracks

From the base plot, we can then add the Best Track data using the lines! function.

using Bagyo
using Colors
using Makie

get(BestTrack, :jma) # download the JMA Best Track
meta, data = load(BestTrack, :jma);
f1, a1 = with_theme(theme_dark(), resolution=(850, 650)) do
	plot(PHL(), :stere);
end;
lines!(a1, data, :jma, linewidth=1, color=RGBAf(1.0, 0.678431, 0.0, 0.15))
a1.title = "Tropical Cyclone Tracks in WNP using JMA";
a1.titlesize = 25;
a1.titlealign = :left;
a1.xlabelpadding = -30;
a1.ylabelpadding = 15;
f1
Note

To run the above code, you need to install the Colors.jl and Makie.jl packages as follows:

using Pkg
Pkg.add("Colors")
Pkg.add("Makie")
Note

The code get(BestTrack, :jma) downloads the JMA Best Track data from the JMA website. Once downloaded, succeeding run will skip this.

Note

First time plotting of the target country, in this case the Philippines (specified by PHL() in the plot function), downloads the polygon for the input country. Once downloaded, succeeding run will skip this.

We added extra theming to the plot above.

Multiple Climate Regions

The following illustrates how to highlight or plot multiple countries' climate regions, these regions correspond to the following countries: Japan, Philippines, Thailand, Taiwan and Vietnam, respectively.

using Bagyo
using Colors
using Makie

f2, a2 = with_theme(theme_dark(), resolution=(850, 650)) do
	plot([JPN(), PHL(), THA(), TWN(), VNM()], :stere);
end;
get(BestTrack, :jma) # download the JMA Best Track, Bagyo.jl automatically skips this if data previously downloaded already
meta, data = load(BestTrack, :jma)
lines!(a2, data, :jma, linewidth=1, color=RGBAf(1.0, 0.678431, 0.0, 0.15))
a2.title = "Tropical Cyclone Tracks in WNP using JMA";
a2.titlesize = 25;
a2.titlealign = :left;
a2.ylabelpadding = 15;
a2.xlabelpadding = -30;
f2
Countries' Climate Regions/Boundaries

The climate boundary above are not official, except for the Philippines. The rest of the climate boundaries of other countries were subjectively provided. Users can specify this, see example in Zooming to Countries' Climate Boundary.

Using IBTrACS

Another example using IBTrACS,

using Bagyo
using Colors
using Makie

f3, a3 = with_theme(theme_dark(), resolution=(850, 650)) do
	plot([JPN(), PHL(), THA(), TWN(), VNM()], :stere);
end;
get(BestTrack, :ibtracs) # download the IBTrACS Best Track, Bagyo.jl automatically skips this if data previously downloaded already
data = load(BestTrack, :ibtracs)
lines!(a3, data, :ibtracs, linewidth=1, color=RGBAf(1.0, 0.678431, 0.0, 0.15))
a3.title = "Tropical Cyclone Tracks in WNP using IBTrACS";
a3.titlesize = 25;
a3.titlealign = :left;
a3.ylabelpadding = 15;
a3.xlabelpadding = -30;
f3

IBTrACS has 4000+ tropical cyclone tracks compared to only 1800+ cyclone tracks recorded by JMA.

Zooming to Countries' Climate Boundary

To zoom in and focus on one country, the configuration needs to be specified at inside the Bagyo.jl types for countries (e.g. PHL, THA, etc.). For example,

get(BestTrack, :ibtracs) # download the IBTrACS Best Track
data = load(BestTrack, :ibtracs);
country = PHL(
	125, # set the center longitude of the map
	10, # set the center latitude of the map
	(110, 145), # set the longitude limits of the map
	(0, 28), # set the latitude limits of the map
	(PHL_AR_LON, PHL_AR_LAT) # add the tuples of arrays for the
							 # longitude and latitude of the climate area monitored
)
f4, a4 = with_theme(theme_dark(), resolution=(770, 650)) do
	plot(country, :gall);
end;
lines!(a4, data, :ibtracs, linewidth=1, color=RGBAf(1.0, 0.678431, 0.0, 0.15))
a4.title = "Tropical Cyclone Tracks in the PAR using IBTrACS";
a4.titlesize = 25;
a4.titlealign = :left;
a4.xlabelpadding = -25;
a4.ylabelpadding = 15;
f4
Country Geodata Specification

The specification of the geodata for the PHL above is also available for other countries available for plotting the Bagyo.jl

Theming

Theming is done using Makie.jl. You can also take inspiration from Beautiful Makie.

get(BestTrack, :ibtracs) # download the IBTrACS Best Track
data = load(BestTrack, :ibtracs);
country = PHL(
	125, # set the center longitude of the map
	10, # set the center latitude of the map
	(110, 145), # set the longitude limits of the map
	(0, 28), # set the latitude limits of the map
	(PHL_AR_LON, PHL_AR_LAT) # add the tuples of arrays for the
							 # longitude and latitude of the climate area monitored
)
f5, a5 = with_theme(theme_light(), resolution=(770, 650)) do
	Bagyo.plot(country, :gall;
	countrystyle = (
		color=colorant"#32a836", # color of the lands of the target country
		strokecolor=:gray, # color of the coastlines of the target country
		strokewidth=1 # width of the coastlines
		),
	landstyle = (
		color=colorant"#1e1c8c", # color of the lands of non-target countries
		strokecolor=:gray, # color of the coastlines of the non-target countries
		strokewidth=1 # width of the coastlines of the non-target countries
	)
	)
end;
lines!(a5, data, :ibtracs, linewidth=1, color=RGBAf(1.0, 0.180, 0.356, 0.15))
a5.title = "Tropical Cyclone Tracks in the PAR using IBTrACS";
a5.titlesize = 25;
a5.titlealign = :left;
a5.xlabelpadding = -25;
a5.ylabelpadding = 15;
f5
Theming

Other arguments for theming the countrystyle is available using Makie.lines arguments. This is true for landstyle as well, and the track styles are also specified inside the lines! function above.

Map Projection

Bagyo.jl uses two main projections, the Gall Stereographic specified by :gall symbol, and the Stereographic specified by :stere. Although you can explore other projections like Cassini projection, it is mainly based on the Proj Project. Also available projections are further constrained to those projections that supports lon_0 and lat_0 parameters.

get(BestTrack, :ibtracs) # download the IBTrACS Best Track
data = load(BestTrack, :ibtracs);
f6, a6 = with_theme(theme_light(), resolution=(850, 650)) do
	plot([JPN(), PHL(), THA(), TWN(), VNM()], :cass;
		countrystyle = (
			color=colorant"#32a836", # color of the lands of the target country
			strokecolor=:gray, # color of the coastlines of the target country
			strokewidth=1 # width of the coastlines
			),
		landstyle = (
			color=colorant"#1e1c8c", # color of the lands of non-target countries
			strokecolor=:gray, # color of the coastlines of the non-target countries
			strokewidth=1 # width of the coastlines of the non-target countries
		)
	);
end;
meta, data = load(BestTrack, :jma)
lines!(a6, data, :jma, linewidth=1, color=RGBAf(1.0, 0.180, 0.356, 0.15))
a6.title = "Tropical Cyclone Tracks under Cassini Projection";
a6.titlesize = 25;
a6.titlealign = :left;
a6.ylabelpadding = 15;
a6.xlabelpadding = -30;
f6