Comparez la forme de différents pays
Utilisez CanonicalWarpingDistance pour trouver les similarités entre les formes de différents pays.
In[1]:=
names = {"USA", "Poland", "Portugal", "Vietnam", "Brazil",
"Finland"};
borders = <|# ->
ArrayResample[CountryData[#, "Polygon"][[1, 1, 1]], 200] & /@
names|>;
In[2]:=
shapes = Graphics[CountryData[#, "Shape"][[1]],
ImageSize -> {50, 50}] & /@ Keys[borders]
Out[2]=
Calculez les distances entre les formes à l'aide de la distorsion temporelle canonique.
In[3]:=
dm = DistanceMatrix[Values[borders],
DistanceFunction -> (Chop[
CanonicalWarpingDistance[##, MaxIterations -> 6]] &)];
Affichez la matrice de distance.
In[4]:=
MatrixPlot[dm,
FrameTicks -> {{MapIndexed[{#2[[1]], #1} &, shapes],
None}, {MapIndexed[{#2[[1]], Rotate[#1, \[Pi]/4]} &, names],
None}}, Mesh -> True, ColorFunction -> "BlueGreenYellow",
PlotLegends -> Automatic,
PlotLabel -> "Distance based on country shape", ImageSize -> Medium]
Out[4]=