# Wolfram Language™

## Compare Weather in Chicago and European Capitals

Find the capital city in the EU that had the most similar temperature to Chicago over the last year. Use WarpingDistance to determine the similarity between temperature sequences.

In:= ```chicagoTemp = WeatherData["Chicago", "Temperature", {{2015, 7}, {2016, 6}, "Week"}, "Value"];```

Get the temperature for all capital cities in the European Union.

In:= `capitals = CityData /@ CountryData["EU", "CapitalCity"] // Sort`
Out= In:= ```capitalsTemp = WeatherData[#, "Temperature", {{2015, 7}, {2016, 6}, "Week"}, "Value"] -> # & /@ capitals;```

Find the capital city that has the most similar temperatures to Chicago.

In:= ```Nearest[capitalsTemp, chicagoTemp, DistanceFunction -> (QuantityMagnitude@WarpingDistance[##] &)]```
Out= Calculate pairwise distances in a matrix.

In:= ```dm = DistanceMatrix[Keys@capitalsTemp, DistanceFunction -> (QuantityMagnitude@WarpingDistance[##] &)];```

Show a 7×7 submatrix of the distance matrix.

In:= `MatrixForm[Take[dm, 7, 7]]`
Out//MatrixForm= Visualize the temperature similarity using a previously computed distance matrix.

show complete Wolfram Language input
In:= ```MatrixPlot[dm, FrameTicks -> {{Transpose[{Range[Length@capitals], capitals}], None}, {Transpose[{Range[Length@capitals], Rotate[#, \[Pi]/2] & /@ capitals}], None}}, Mesh -> True, ColorFunction -> "BlueGreenYellow", PlotLegends -> Placed[Automatic, Above], PlotLabel -> "Distance based on temperature", ImageSize -> Large]```
Out= 