hitautodestruct hitautodestruct - 22 days ago 11
Javascript Question

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
's the full object.

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

Does anyone know what temperature unit openweathermap is returning?


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

And the briefest glance at the API documentation tells us that if you add &units=metric to your request, you'll get back celsius.