Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I calculate the temperature in celsius returned in openweathermap.org JSON?

I'm getting the weather for a city using openweathermap.org.

The jsonp call is working and everything is fine but the resulting object contains the temperature in an unknown unit:

{     //...     "main": {         "temp": 290.38, // What unit of measurement is this?         "pressure": 1005,         "humidity": 72,         "temp_min": 289.25,         "temp_max": 291.85     },     //... } 

Here is a demo that console.log's the full object.

I don't think the resulting temperature is in fahrenheit because converting 290.38 fahrenheit to celsius is 143.544.

Does anyone know what temperature unit openweathermap is returning?

like image 963
hitautodestruct Avatar asked Oct 20 '13 12:10

hitautodestruct


People also ask

How do you convert API temp to Celsius?

Converting kelvin to celsius is easy: Just subtract 273.15. Looking at the API documentation, if you add &units=metric to your request, you'll get back celsius.

What does DT mean in OpenWeatherMap?

Explanation of the parameters: http://openweathermap.org/weather-data#current. dt : Data receiving time (in unix, UTC format). dt is the time of data receiving in unixtime GMT (greenwich mean time).

How accurate is OpenWeatherMap?

We analysed the behaviour of metrics for the OpenWeather NMP model during two months. The figure shows that MAE is about 0.5 degrees, RMSE is less than 2 degrees, reliability is between 90% and 100%, and inaccuracy is about 1% (less is better).

How do I use OpenWeatherMap key?

The API key is all you need to call any of our weather APIs. Once you sign up using your email, the API key (APPID) will be sent to you in a confirmation email. Your API keys can always be found on your account page, where you can also generate additional API keys if needed.


2 Answers

It looks like kelvin. Converting kelvin to celsius is easy: Just subtract 273.15.

Looking at the API documentation, if you add &units=metric to your request, you'll get back celsius.

like image 118
T.J. Crowder Avatar answered Sep 24 '22 23:09

T.J. Crowder


That appears to be kelvin, but you can specify the format you want returned for the temp, e.g.:

http://api.openweathermap.org/data/2.5/weather?q=London&mode=json&units=metric

or

http://api.openweathermap.org/data/2.5/weather?q=London&mode=json&units=imperial

like image 38
spacebean Avatar answered Sep 24 '22 23:09

spacebean