Adding real-time weather data from OpenWeatherMap
Real-time data is one of the most exciting data types you can add to a modern map. Most data producers make data available through Open GIS Consortium standards. One such example is OpenWeatherMap, which offers an OGC Web Map Service (WMS) for different real-time weather data layers. In this recipe, we'll access this service to access a real-time weather data layer.
Getting ready
To prepare for this recipe, you just need to open the QGIS Python Console by clicking on the Plugins menu and selecting Python Console.
How to do it...
We will add a WMS weather data layer for precipitation to a QGIS map, as follows:
First, we specify the parameters for the
service
:service = 'crs=EPSG:900913&dpiMode=7&featureCount=10&format=image/png&layers=precipitation&styles=&url=http://wms.openweathermap.org/service'
Next, we create the raster layer, specifying
wms
as the type:rlayer = QgsRasterLayer(service, "precip", "wms")
Finally, we add...