Met Office Weather Maps PHP API

来源:互联网 时间:1970-01-01

For those who want to add detailed weather maps of the UK to their websites anexcellent option is to usethe Met Office’s Datapoint web serviceAPI. Among many other features the APImakes available severaldifferent 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 utilisethe 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 requiringusers to directly engage with the Datapoint API.

It’s functionality includes:

Wrapping the complexity of underlying JSON web servicecalls 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 UTC timestamps to map images where they are not already present. Producing GIF animations of every map’s time series. Producing thumbnails of every map image. Operating caching to allow maps to be requested on a regular schedule. This ensures that the latest maps are fetchedwithout making excessive calls to DataPoint which may breach their fair use agreement.

The met-office-weather-maps API supports all of theDataPoint 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 fromDataPoint is a transparent layer depicting isobars and fronts:

Click to Enlarge

The same imageafter processing by met-office-weather-maps . Note the addition of a timestamp and a grey scale base image of the UK:

Click to Enlarge

Example 2: InfraredSatellite Map

The Infrared Satellite imageavailable fromDataPoint is an opaque layer depicting cloud cover as viewed in infrared:

The same imageafter 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 TemperatureForecast imageavailable fromDataPoint is a partiallytransparentlayer depicting colour-codedscreen temperature:

Click to Enlarge

The same imageafter processing by met-office-weather-maps . Note the additionof a timestamp, a grey scale base image and a blackoutline overlay image of the UK:

Click to Enlarge

Example 4: Cloud Cover andPrecipitation Forecast Map

The Cloud Cover andPrecipitation Forecast imageavailable fromDataPoint is a transparentlayer depicting cloud cover and colour-coded precipitation rates:

Click to Enlarge

The same imageafter 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:

Click to Enlarge

Example 5: Animation of Map’s Time Series

AGIF animation produced by the API of the Cloud Cover and Precipitation Forecast time series:

Click to Enlarge

,,,You can, or

from your own site.

相关阅读:
Top