Wolfram Language™

Tunnels

TunnelData provides information about tunnels, such as their length and the location.

In:= tunnels = TunnelData[];
In:= Length[tunnels]
Out= For each tunnel, find its length and location given by country or countries.

In:= rawData = TunnelData[tunnels, {"Countries", "Length"}];

Clean the data to remove missing values.

In:= data = DeleteMissing[rawData, 1, 2];

Convert the length data to miles.

In:= data[[All, 2]] = UnitConvert[N[data[[All, 2]]], "Miles"];
In:= lengths = data[[All, 2]];
In:= MinMax[lengths]
Out= In:= h = Histogram[lengths, {1, 12, .5}, PDF, FrameLabel -> Automatic, PlotTheme -> "Detailed"]
Out= The data might be described by a mixture of long-tailed distributions.

In:= dist = MixtureDistribution[{w1, w2}, {ParetoDistribution[a1, a2, a3, a4], WeibullDistribution[b1, b2]}];
In:= edist = EstimatedDistribution[lengths, dist]
Out= Test goodness of fit against the parametric family mixture distributions.

In:= DistributionFitTest[lengths, dist, "TestDataTable"]
Out= Plot the PDF of the fitted distribution against the histogram.

In:= Show[h, Plot[PDF[edist, Quantity[x, "Miles"]], {x, 1, 12}, PlotRange -> All] // Quiet]
Out= Visualize the locations of the tunnels.

Group by country.

In:= res = GroupBy[data, First, Flatten[Take[#, All, -1]] &];

Some tunnels are located in more than one country.

In:= shared = Select[Keys[res], Length[#] > 1 &]
Out= Distribute the shared tunnels and select countries that have at least 10 tunnels. Plot the length distribution chart.

show complete Wolfram Language input
In:= split = GroupBy[ Flatten[Map[{{{#[]}, res[#]}, {{#[]}, res[#]}} &, shared], 1], First, Flatten[#[[All, 2]]] &];
In:= together = Join[KeyDrop[res, shared], split, 2];
In:= tc = SortBy[Select[Normal[together], Length[#[]] >= 10 &], Length@*Last];
In:= DistributionChart[tc[[All, 2]], ChartLabels -> tc[[All, 1, 1]], BarOrigin -> Left, BarSpacing -> .3, FrameLabel -> {"Miles"}, LabelingFunction -> (Placed[Length[#1], After] &), ChartStyle -> "SandyTerrain", ImageSize -> Large]
Out= The total tunnel mileage per country with shared tunnels included in full length for each country.

show complete Wolfram Language input
In:= vals = KeyMap[First, Map[Total, together]]; title = Style["tunnel mileage", 24, Bold, GrayLevel[.2], FontFamily -> "Osaka"]; GeoRegionValuePlot[vals, GeoProjection -> "Mercator", GeoRange -> {{-65, 80}, {-170, 190}}, PlotLegends -> Automatic, ColorFunction -> (ColorData["StarryNightColors", 2 #] &), Epilog -> Inset[title, {30, -65}], ImageSize -> 500]
Out= 