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.
To prepare for this recipe, you just need to open the QGIS Python Console by clicking on the Plugins menu and selecting Python Console.
We will add a WMS weather data layer for precipitation to a QGIS map, as follows:
service
:service = 'crs=EPSG:900913&dpiMode=7&featureCount=10&format=image/png&layers=precipitation&styles=&url=http://wms.openweathermap.org/service'
wms
as the type:rlayer = QgsRasterLayer(service, "precip", "wms")
QgsMapLayerRegistry.instance().addMapLayers([rlayer])