Callysto.ca Banner

Open in Callysto

Hourly Weather in Canada

The National Office of Climate Services at Environment and Climate Change Canada has a dataset of weather measurements at monthy, daily, or even hourly intervals for almost 9000 weather stations. Check out this example for YEG Christmas 2019.

List of Weather Stations

Let’s start by importing and mapping the locations of all of the weather stations.

import pandas as pd
import requests
from io import StringIO
stations_url = 'https://drive.google.com/uc?export=download&id=1egfzGgzUb0RFu_EE5AYFZtsyXPfZ11y2'
stations = pd.read_csv(StringIO(requests.get(stations_url).text), header=3)
stations.drop(columns=['Latitude','Longitude'], inplace=True)
stations.rename(columns={'Latitude (Decimal Degrees)':'Latitude','Longitude (Decimal Degrees)':'Longitude'}, inplace=True)
stations
Name Province Climate ID Station ID WMO ID TC ID Latitude Longitude Elevation (m) First Year Last Year HLY First Year HLY Last Year DLY First Year DLY Last Year MLY First Year MLY Last Year
0 ACTIVE PASS BRITISH COLUMBIA 1010066 14 NaN NaN 48.87 -123.28 4.0 1984 1996 NaN NaN 1984.0 1996.0 1984.0 1996.0
1 ALBERT HEAD BRITISH COLUMBIA 1010235 15 NaN NaN 48.40 -123.48 17.0 1971 1995 NaN NaN 1971.0 1995.0 1971.0 1995.0
2 BAMBERTON OCEAN CEMENT BRITISH COLUMBIA 1010595 16 NaN NaN 48.58 -123.52 85.3 1961 1980 NaN NaN 1961.0 1980.0 1961.0 1980.0
3 BEAR CREEK BRITISH COLUMBIA 1010720 17 NaN NaN 48.50 -124.00 350.5 1910 1971 NaN NaN 1910.0 1971.0 1910.0 1971.0
4 BEAVER LAKE BRITISH COLUMBIA 1010774 18 NaN NaN 48.50 -123.35 61.0 1894 1952 NaN NaN 1894.0 1952.0 1894.0 1952.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
8761 WEST ST MODESTE NEWFOUNDLAND 8504216 6803 NaN NaN 51.60 -56.70 12.2 1990 2002 NaN NaN 1990.0 2002.0 1990.0 2002.0
8762 WEST ST MODESTE NEWFOUNDLAND 8504217 6804 NaN NaN 51.58 -56.72 15.2 1984 1987 NaN NaN 1984.0 1987.0 1984.0 1987.0
8763 CHURCHILL FALLS NEWFOUNDLAND 850A131 6940 NaN NaN 53.53 -63.97 488.5 1993 1998 NaN NaN 1993.0 1998.0 1993.0 1998.0
8764 MAKKOVIK (AUT) NEWFOUNDLAND 850B5HR 9025 NaN NaN 55.08 -59.17 71.3 1985 1986 1985.0 1986.0 NaN NaN NaN NaN
8765 MARY'S HARBOUR NEWFOUNDLAND 850B5R1 10227 71339.0 YMH 52.30 -55.83 11.6 1992 2014 1994.0 2014.0 1992.0 2013.0 2005.0 2007.0

8766 rows × 17 columns

print('This will map will take a minute or two to create with', len(stations), 'weather stations.')
import folium
from folium.plugins import MarkerCluster
latitude = stations['Latitude'].mean()
longitude = stations['Longitude'].mean()
station_map = folium.Map(location=[latitude,longitude], zoom_start=3)
marker_cluster = MarkerCluster()
for row in stations.itertuples():
    marker_cluster.add_child(folium.Marker(location=[row.Latitude,row.Longitude], tooltip=row.Name, popup=row._4))
station_map.add_child(marker_cluster)
print('You can zoom, pan, and click to expand markers. Clicking on a marker will display its station ID.')
station_map
This will map will take a minute or two to create with 8766 weather stations.
You can zoom, pan, and click to expand markers. Clicking on a marker will display its station ID.
Make this Notebook Trusted to load map: File -> Trust Notebook

Station Data Availability

You can check out the data available for a particular station.

station_id = 6454
stations[stations['Station ID']==station_id]
Name Province Climate ID Station ID WMO ID TC ID Latitude Longitude Elevation (m) First Year Last Year HLY First Year HLY Last Year DLY First Year DLY Last Year MLY First Year MLY Last Year
8284 SABLE ISLAND NOVA SCOTIA 8204700 6454 71600.0 ESA 43.93 -60.01 5.0 1891 2017 1953.0 2016.0 1891.0 2017.0 1891.0 2007.0

Filtering Station Data

You can select just a subset of the data. For example, finding stations that are currently collecting hourly weather data.

stations[stations['HLY Last Year']>2019]
Name Province Climate ID Station ID WMO ID TC ID Latitude Longitude Elevation (m) First Year Last Year HLY First Year HLY Last Year DLY First Year DLY Last Year MLY First Year MLY Last Year
28 DISCOVERY ISLAND BRITISH COLUMBIA 1012475 27226 71031.0 WDR 48.42 -123.23 18.93 1997 2020 1997.0 2020.0 1997.0 2020.0 1998.0 2005.0
39 ESQUIMALT HARBOUR BRITISH COLUMBIA 1012710 52 71798.0 WPF 48.43 -123.44 3.00 1957 2020 1994.0 2020.0 1957.0 2020.0 1957.0 2005.0
49 KELP REEFS BRITISH COLUMBIA 1013998 10853 NaN WZO 48.55 -123.24 0.00 1997 2020 1997.0 2020.0 2018.0 2020.0 NaN NaN
54 MALAHAT BRITISH COLUMBIA 1014820 65 71774.0 WKH 48.57 -123.53 365.80 1920 2020 1994.0 2020.0 1920.0 2020.0 1920.0 2005.0
67 NORTH COWICHAN BRITISH COLUMBIA 1015630 46728 71927.0 VOO 48.82 -123.72 44.80 2007 2020 2007.0 2020.0 2007.0 2020.0 NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
8739 NAIN A NEWFOUNDLAND 8502801 53507 71902.0 YDP 56.55 -61.68 6.40 2015 2020 2015.0 2020.0 2015.0 2018.0 NaN NaN
8740 NAIN A NEWFOUNDLAND 8502810 53502 NaN YDP 56.55 -61.68 6.40 2015 2020 2015.0 2020.0 2018.0 2020.0 NaN NaN
8751 SAGLEK NEWFOUNDLAND 8503249 6797 71335.0 WZZ 58.33 -62.59 516.00 1989 2020 1989.0 2020.0 1989.0 2020.0 1989.0 1993.0
8759 WABUSH A NEWFOUNDLAND 8504176 51057 NaN YWK 52.92 -66.86 551.40 2013 2020 2013.0 2020.0 2013.0 2014.0 NaN NaN
8760 WABUSH A NEWFOUNDLAND 8504177 52541 71825.0 YWK 52.92 -66.86 551.40 2014 2020 2014.0 2020.0 2014.0 2020.0 NaN NaN

1136 rows × 17 columns

Mapping Filtered Data

Let’s make a map of that filtered dataset.

current_hourly = stations[stations['HLY Last Year']>2019]
print('Creating a map for', len(current_hourly), 'stations with current hourly weather.')
current_hourly_map = folium.Map(location=[latitude,longitude], zoom_start=3)
ch_marker_cluster = MarkerCluster()
for row in current_hourly.itertuples():
    ch_marker_cluster.add_child(folium.Marker(location=[row.Latitude,row.Longitude], tooltip=row.Name, popup=row._4))
current_hourly_map.add_child(marker_cluster)
current_hourly_map
Creating a map for 1136 stations with current hourly weather.
Make this Notebook Trusted to load map: File -> Trust Notebook

Weather Data

Once you have selected a station, you can then import a month worth of hourly weather data.

station_id = 50149
year = 2019
month = 12
url_start = 'https://climate.weather.gc.ca/climate_data/bulk_data_e.html?format=csv&stationID='
url = url_start+str(station_id)+'&Year='+str(year)+'&Month='+str(month)+'&Day=14&timeframe=1&submit=Download+Data'
weather = pd.read_csv(url)
weather
Longitude (x) Latitude (y) Station Name Climate ID Date/Time Year Month Day Time Temp (°C) ... Wind Spd Flag Visibility (km) Visibility Flag Stn Press (kPa) Stn Press Flag Hmdx Hmdx Flag Wind Chill Wind Chill Flag Weather
0 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-01 00:00 2019 12 1 00:00 -19.1 ... NaN 24.1 NaN 92.78 NaN NaN NaN -27.0 NaN NaN
1 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-01 01:00 2019 12 1 01:00 -18.7 ... NaN 32.2 NaN 92.70 NaN NaN NaN -27.0 NaN NaN
2 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-01 02:00 2019 12 1 02:00 -19.3 ... NaN 32.2 NaN 92.65 NaN NaN NaN -26.0 NaN Clear
3 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-01 03:00 2019 12 1 03:00 -21.0 ... NaN 32.2 NaN 92.62 NaN NaN NaN -25.0 NaN NaN
4 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-01 04:00 2019 12 1 04:00 -19.8 ... NaN 32.2 NaN 92.61 NaN NaN NaN -25.0 NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
739 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-31 19:00 2019 12 31 19:00 -0.2 ... NaN 32.2 NaN 90.96 NaN NaN NaN -1.0 NaN NaN
740 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-31 20:00 2019 12 31 20:00 -2.0 ... NaN 32.2 NaN 90.91 NaN NaN NaN -3.0 NaN Cloudy
741 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-31 21:00 2019 12 31 21:00 -3.1 ... NaN 32.2 NaN 90.85 NaN NaN NaN -6.0 NaN NaN
742 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-31 22:00 2019 12 31 22:00 -2.8 ... NaN 32.2 NaN 90.83 NaN NaN NaN -7.0 NaN NaN
743 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-31 23:00 2019 12 31 23:00 -1.2 ... NaN 32.2 NaN 90.77 NaN NaN NaN -4.0 NaN Cloudy

744 rows × 28 columns

You can also look at just one day of weather data from that data set.

weather_day = weather[weather['Day']==25]
weather_day
Longitude (x) Latitude (y) Station Name Climate ID Date/Time Year Month Day Time Temp (°C) ... Wind Spd Flag Visibility (km) Visibility Flag Stn Press (kPa) Stn Press Flag Hmdx Hmdx Flag Wind Chill Wind Chill Flag Weather
576 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 00:00 2019 12 25 00:00 -4.6 ... NaN 6.4 NaN 92.08 NaN NaN NaN -9.0 NaN Snow,Fog
577 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 01:00 2019 12 25 01:00 -6.0 ... NaN 6.4 NaN 92.08 NaN NaN NaN -9.0 NaN Snow,Fog
578 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 02:00 2019 12 25 02:00 -6.6 ... NaN 9.7 NaN 92.12 NaN NaN NaN -10.0 NaN Snow,Fog
579 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 03:00 2019 12 25 03:00 -7.3 ... NaN 16.1 NaN 92.16 NaN NaN NaN -12.0 NaN Snow
580 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 04:00 2019 12 25 04:00 -8.9 ... NaN 9.7 NaN 92.20 NaN NaN NaN -14.0 NaN Snow,Fog
581 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 05:00 2019 12 25 05:00 -9.6 ... NaN 4.8 NaN 92.24 NaN NaN NaN -14.0 NaN Snow,Fog
582 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 06:00 2019 12 25 06:00 -12.2 ... NaN 16.1 NaN 92.28 NaN NaN NaN -18.0 NaN NaN
583 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 07:00 2019 12 25 07:00 -13.8 ... NaN 24.1 NaN 92.32 NaN NaN NaN -18.0 NaN NaN
584 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 08:00 2019 12 25 08:00 -17.1 ... NaN 32.2 NaN 92.37 NaN NaN NaN -22.0 NaN Mainly Clear
585 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 09:00 2019 12 25 09:00 -16.8 ... NaN 32.2 NaN 92.40 NaN NaN NaN -21.0 NaN NaN
586 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 10:00 2019 12 25 10:00 -16.0 ... NaN 32.2 NaN 92.48 NaN NaN NaN -22.0 NaN NaN
587 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 11:00 2019 12 25 11:00 -12.1 ... NaN 32.2 NaN 92.53 NaN NaN NaN -15.0 NaN Mainly Clear
588 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 12:00 2019 12 25 12:00 -9.6 ... NaN 32.2 NaN 92.57 NaN NaN NaN -14.0 NaN NaN
589 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 13:00 2019 12 25 13:00 -8.3 ... NaN 32.2 NaN 92.58 NaN NaN NaN -14.0 NaN NaN
590 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 14:00 2019 12 25 14:00 -7.9 ... NaN 32.2 NaN 92.60 NaN NaN NaN -13.0 NaN Clear
591 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 15:00 2019 12 25 15:00 -8.1 ... NaN 32.2 NaN 92.66 NaN NaN NaN -13.0 NaN NaN
592 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 16:00 2019 12 25 16:00 -9.0 ... NaN 32.2 NaN 92.72 NaN NaN NaN -14.0 NaN NaN
593 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 17:00 2019 12 25 17:00 -9.9 ... NaN 32.2 NaN 92.77 NaN NaN NaN -14.0 NaN Clear
594 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 18:00 2019 12 25 18:00 -12.8 ... NaN 32.2 NaN 92.81 NaN NaN NaN -19.0 NaN NaN
595 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 19:00 2019 12 25 19:00 -12.8 ... NaN 32.2 NaN 92.84 NaN NaN NaN -19.0 NaN NaN
596 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 20:00 2019 12 25 20:00 -11.7 ... NaN 32.2 NaN 92.86 NaN NaN NaN -18.0 NaN Mainly Clear
597 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 21:00 2019 12 25 21:00 -12.9 ... NaN 32.2 NaN 92.85 NaN NaN NaN -20.0 NaN NaN
598 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 22:00 2019 12 25 22:00 -11.2 ... NaN 32.2 NaN 92.86 NaN NaN NaN -18.0 NaN NaN
599 -113.58 53.31 EDMONTON INTL A 3012216 2019-12-25 23:00 2019 12 25 23:00 -12.2 ... NaN 32.2 NaN 92.88 NaN NaN NaN -19.0 NaN Mainly Clear

24 rows × 28 columns

Callysto.ca License