Met Office Weather Maps PHP API
For those who want to add detailed weather maps of the UK to their websites an excellent option is to use the Met Office’s DataPoint web service API. Among many other features the API makes available several different types of observation and forecast time series weather maps as detailed images.
However, DataPoint still leaves users with a lot of work to do if they want to utilise the maps on their websites. For example the DataPoint API only provides the map images as simple layers with no underlying map of the UK. This gives users the flexibility of adding their own UK maps but creates one of many common problems that all DataPoint users have to solve individually.
To address this and other website integration issues I’ve made the met-office-weather-maps PHP API available on GitHub under the MIT License. It’s primary use case is to make it easier to incorporate the latest Met Office weather maps into a web site while not requiring users to directly engage with the Datapoint API.
It’s functionality includes:
- Wrapping the complexity of underlying JSON web service calls by exposing one simple PHP class for each available map type.
- Adding tailored UK map layers to fetched images that obey the required Mercator projection boundary box.
- Adding UK timestamps to map images where they are not already present.
- Operating caching to allow maps to be requested on a regular schedule. This ensures that the latest maps are fetched without making excessive calls to DataPoint which may breach their fair use agreement.
The met-office-weather-maps API supports all of the DataPoint map types:
- Infrared satellite
- Lightning strikes
- Precipitation forecast
- Pressure forecast
- Rainfall radar
- Surface pressure charts
- Temperature forecast
- Total cloud cover forecast
- Total cloud cover and precipitation forecast
- Visible satellite
See the met-office-weather-maps Git Hub project page for details of its requirements, installation and API documentation.
I originally wrote met-office-weather-maps for incorporation into my own weather website where I regularly fetch a selection of weather maps. I previously used Weather Underground’s map API but I find DataPoint to be far superior in terms of map selection and the high frequency of map update.
See below for some real examples that demonstrate met-office-weather-map’s capabilities.
Example 1: Surface Pressure Forecast Map
The Surface Pressure Forecast image available from DataPoint is a transparent layer depicting isobars and fronts:
The same image after processing by met-office-weather-maps. Note the addition of a timestamp and a colour base image of the UK:
Example 2: Visible Satellite Map
The Visible Satellite image available from DataPoint is an opaque layer depicting cloud cover:
The same image after processing by met-office-weather-maps. Note the addition of a yellow outline overlay image of the UK which does not obscure the existing image layer’s timestamp and key:
Example 3: Temperature Forecast Map
The Temperature Forecast image available from DataPoint is a partially transparent layer depicting colour-coded screen temperature:
The same image after processing by met-office-weather-maps. Note the addition of a timestamp, a colour base image and a black outline overlay image of the UK:
Example 4: Cloud Cover and Precipitation Forecast Map
The Cloud Cover and Precipitation Forecast image available from DataPoint is a transparent layer depicting cloud cover and colour-coded precipitation rates:
The same image after processing by met-office-weather-maps. Note the addition of a timestamp, a colour base image and a black outline overlay image of the UK:
Explore posts in the same categories: Code Projects, Meteorology, Open Source, Weather StationTags: Met Office, Meteorology, PHP, Weather, Weather Station
You can comment below, or link to this permanent URL from your own site.
November 4, 2016 at 11:35 am
Thank you for this very helpful guide, nice weather maps.