Meteostat Python Library

2.1.4 · active · verified Mon Apr 13

Meteostat is an open-source Python library that provides an easy and efficient way to access and analyze historical weather and climate data. It retrieves observations and statistics from Meteostat's bulk data interface, which aggregates information from various public sources, including national weather services like NOAA and DWD. The library is currently at version 2.1.4 and is actively maintained with a focus on performance improvements and a consistent API experience.

Warnings

Install

Imports

Quickstart

This quickstart code demonstrates how to fetch and plot daily temperature data for a specific geographical point (Frankfurt, Germany) using the `meteostat` library. It involves defining a `Point`, specifying a date range, finding nearby stations, fetching and interpolating daily data, and then plotting the average, minimum, and maximum temperatures.

from datetime import date
import matplotlib.pyplot as plt
import meteostat as ms

# Specify location and time range for Frankfurt, Germany
POINT = ms.Point(50.1155, 8.6842, 113)
START = date(2018, 1, 1)
END = date(2018, 12, 31)

# Get nearby weather stations
stations = ms.stations.nearby(POINT, limit=4)

# Get daily data & perform interpolation
ts = ms.daily(stations, START, END)
df = ms.interpolate(ts, POINT).fetch()

# Plot line chart including average, minimum and maximum temperature
df.plot(y=[ms.Parameter.TEMP, ms.Parameter.TMIN, ms.Parameter.TMAX])
plt.title('2018 Temperature Data for Frankfurt, Germany')
plt.xlabel('Date')
plt.ylabel('Temperature (°C)')
plt.show()

view raw JSON →