'How do I get wind in km/h in PyOWM?
I made a program that retrieves the current weather in users city using PyOWM.
I am having trouble understanding how to display wind using km/h in PyOWM.
I tried making conversions but when I checked the current weather on Google, it was always wrong.
Does the weather update every hour? The code in question:
print("Wind:",round((w.wind().get("speed",0)),2),"km/h")
w being observation.weather, observation being mgr.weather_at_place(asd), asd being location of user input
Full Code:
from pyowm import OWM
country = input("Enter your country code: ")
city = input("Enter your city name: ")
owm = OWM("xxxxxxxxx")
mgr = owm.weather_manager()
asd = city + ", " + country
observation = mgr.weather_at_place(asd)
w = observation.weather
w.wind()
print("Wind:", round((w.wind().get("speed", 0)), 2), "km/h")
Solution 1:[1]
It gives the windspeed in m/s. You need to convert it to km/h by multiplying the returned value by 3.6.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | BrokenBenchmark |