Today we are announcing the first stable release of the Meteostat Python library on PyPI. With version 1.0.0, the library becomes much more mature and performant. Furthermore, future minor releases will guarantee full compatibility from version 1.0 upwards.
With our Python library we wanted to build a scalable solution which allows users to analyze historical weather and climate data on a large scale — both time-wise and geographically. In contrast to the Meteostat JSON API, the library provides unlimited data access and doesn’t require users to sign up. This is made possible with the help of Cloudflare, a global CDN provider, which allows Meteostat to serve data dumps relatively fast — no matter where you are. The ability to provide large amounts of data through a flexible, open and free interface makes the Meteostat project even more suitable for data science use cases.
The Meteostat Python package is available through PyPI. Therefore, installing the library is as easy as running this command:
pip install meteostat
Once the package is installed, you can start analyzing historical weather and climate data without limits.
The library features a detailed documentation with a lot of examples and details about the library’s API. Essentially, the package provides three classes which give you access to historical weather and climate data:
- Stations: Filter available weather stations
- Hourly: Access hourly weather data
- Daily: Access daily weather data
Stations class is useful if you do not have a specific weather station ID at hand. It provides different filters for finding weather stations which are suitable for your use case. A common task is the lookup of the closest weather station to a certain geographical location. Take a look at this example:
# Import Meteostat library and dependencies
from datetime import datetime
import matplotlib.pyplot as plt
from meteostat import Stations, Daily
# Set coordinates of Vancouver
lat = 49.2497
lon = -123.1193
# Set time period
start = datetime(2018, 1, 1)
end = datetime(2018, 12, 31)
# Get closest weather station to Vancouver, BC
stations = Stations()
stations = stations.nearby(lat, lon)
stations = stations.inventory('daily', (start, end))
station = stations.fetch(1)
# Get daily data for 2018 at the selected weather station
data = Daily(station, start, end)
data = data.fetch()
# Plot line chart including average, minimum and maximum temperature
data.plot(y=['tavg', 'tmin', 'tmax'])
plt.show()Code language: Python (python)
The example prints a 2018 temperature chart for the city of Vancouver, BC using the
Daily class. The data access does not require knowledge about the available weather stations and could easily be adapted to another location.
More examples and explanations are available in the documentation.
Once the library has settled and we do have some experience with how exactly people are using it, we will proceed with adding monthly data and an interface which provides regional averages. Furthermore, on mid to long-term distance, we want to move from Creative Commons Attribution-NonCommercial 4.0 International Public License to a license which enables commercial usage of meteorological data.
Also, we want to focus on stabilizing what is already there and implementing additional data sources. Going forward, all coding of the project will be open sourced under the MIT license.
If you want to get involved in the development of the Meteostat Python library, are running into an issue or just want to give some feedback, please refer to the GitHub repository. Also, you can support our work with a donation or by becoming a patron of Meteostat.
Let’s continue to democratize weather and climate data!