Banner

Wednesday, 11 June 2014

How is the weather at this latitude, longitude location?

In my last blog post, we saw how to find the name and altitude of a latitude, longitude location. Today, I want to see what the weather is like. In Norway, we have a great free weather service, yr.no, that also comes with an API (with world coverage!). I'm going to use it to log the weather on my expedition map.

yr.no is a joint weather service from the Norwegian Meteorological Institute (met.no) and the Norwegian Broadcasting Corporation (NRK). yr.no is unique in Europe because of very detailed weather forecasts and a free data policy.

I'm using the location forecast API (terms of use), which returns the weather forecast for a latitude, longitude location:

http://api.yr.no/weatherapi/locationforecast/1.9/?lat=59.33895;lon=5.96639

It returns an XML with a 9 days forecast starting from the current hour. I'm only logging the current time forecast for my expedition map.

I know it's totally useless, but this is my SPOT logging my current location so I can find the weather without looking up on the sky... 

I've made a PHP cron job that that adds weather data to my SPOT Satellite Messenger locations, that are already synced to CartoDB. For these locations I already have the latitude, longitude and the time it was recorded.


I'm first asking for a full weather forecast from the API. Then I'm using XPath to find the weather for the nearest hour. Data on temperature, precipitation, wind and the weather symbol is added to the CartoDB-table. I'm also calculating the sunrise and sunset time to get the correct weather symbol (to show the sun or the moon).

The weather data will be shown in the popups, and I'm going to play with the weather recordings after my expedition.

Showing the weather on the same location as the photo above. It's a bit chilly today with 14°C, sunny and a moderate breeze, 7 m/s from southwest - which is quite correct from my real-time experience :-) 

So, we've enriched our satellite positions with location and weather data. But what would an expedition map be without photos? It's the topic of my next blog post.   

2 comments:

Anonymous said...

Hey! Really nice work!
Do you know if it's possible to get the forecast from a specific date we set (as we were searching back in their database)?
If I understood this database just provides the forecast based on the current time.

Thank you!

Bruno.

Anonymous said...

Hey! Really nice work!
Do you know if it's possible to get the forecast from a specific date we set (as we were searching back in their database)?
If I understood this database just provides the forecast based on the current time.

Thank you!

Bruno.