openweathermap - 서울 날씨 정보 확인하기, 웹에서 서울 날씨 정보 확인하기, API로 서울 날씨 정보 가져오기, 날씨 정보 JSON, 온도 단위 변환 (℉ -> ℃)

CODEDRAGON Development/Software Engineering

반응형

 

 

 

openweathermap - 서울 날씨 정보 확인하기

·         웹에서 서울 날씨 정보 확인하기

·         API 서울 날씨 정보 가져오기

·         날씨 정보 JSON

·         온도 단위 변환 ( -> )

 

 


 

 

웹에서 서울 날씨 정보 확인하기

 

홈페이지에 접속

http://openweathermap.org/

 

"Seoul" 확인할 도시명을 입력한 >> [Search] 클릭

Seoul

 

검색된 해당 도시의 날씨정보가 출력됩니다.

 

 

Seoul, KR  haze
13°С  temperature from 12 to 14 °С, wind 4.6 m/s. clouds 75 %, 1011 hpa
 
Geo coords [37.5667, 126.9783]

 

[Seoul, KR] 도시명 링크를 클릭하면 상세한 날씨정보를 확인할 있습니다.

https://openweathermap.org/city/1835848

 

 

 

API 서울 날씨 정보 가져오기

현재 도시의 날씨 정보 요청 API 호출 형식

http://api.openweathermap.org/data/2.5/weather?id=[City_ID]&appid=[Your_API_Key_here]

 

 

  

발급 받은 API 통해 서울의 날짜 정보 가져오기

http://samples.openweathermap.org/data/2.5/weather?id=2172797&appid=[Your_API_Key_here]

 

 

 

 

날씨 정보 JSON

날씨 정보는 JSON타입으로 반환됩니다.

 
{    "coord": {"lon":126.98,"lat":37.57},
"weather":[ {"id":721,"main":"Haze","description":"haze","icon":"50d"}],
"base":"stations",
"main": {"temp":286.14,"pressure":1011,"humidity":54,"temp_min":285.15,"temp_max":287.15},
"visibility":10000,
"wind": {"speed":4.6,"deg":270},
"clouds": {"all":75},
"dt":1523768400,
"sys": {"type":1,"id":7676,"message":0.0055,"country":"KR","sunrise":1523739459,"sunset":1523786836},
"id":1835848,"name":"Seoul","cod":200
}
 
 
{    "coord": {"lon":경도,"lat":위도},
"weather":[ {"id":721,"main":"날씨","description":"날씨 상세 정보","icon":"50d"}],
"base":"stations",
"main": {"temp":온도,"pressure":대기압,"humidity":습도,"temp_min":최저기온,"temp_max":최고기온},
"visibility":10000,
"wind": {"speed":풍속,"deg":풍향},
"clouds": {"all":구름정도},
"dt":시간,
"sys": {"type":1,"id":7676,"message":0.0055,"country":"국가코드","sunrise":1523739459,"sunset":1523786836},
"id":도시아이디,"name":"도시이름","cod":200
}
 

 

 

온도 단위 변환 ( -> )

"main.temp" 필드에 켈빈 온도로 표시되어 있는데 이를 섭씨온도로 변환하기 위해서는 273.15 빼주면 됩니다.

 

- 273.15 =
286.14 - 273.15 = 12.99

 

 

 

 

반응형