Open saltymaverick opened 1 year ago
Hi,
What's your value for lat
, lon
and radius
? It might well be that the weather stations in this area don't provide wpgt
data.
from meteostat import Stations, Daily, Point
def get_latitude_longitude(address):
geolocator = Nominatim(user_agent="geoapiExercises")
try:
location = geolocator.geocode(address)
if location:
return location.latitude, location.longitude
else:
return None, None
except GeocoderTimedOut:
return get_latitude_longitude(address)
if __name__ == "__main__":
address = input("Enter the address: ")
latitude, longitude = get_latitude_longitude(address)
if latitude and longitude:
print(f"Latitude: {latitude}, Longitude: {longitude}")
else:
print("Location not found.")
lat = latitude
lon = longitude
radius = 100000 # meters
num_stations = 5
start = datetime(2022, 9, 11)
end = datetime(2022, 11, 9)
for index, station in stations.iterrows():
station_id = station['icao']
station_name = station['name']
station_lat = station['latitude']
station_lon = station['longitude']
station_ele = station.elevation
point = Point(station_lat, station_lon, station_ele)
data = Daily(point, start, end)
data = data.fetch()
for index, row in data.iterrows():
station_info = {
"station": [station_id],
"staion name": [station_name],
"time": [index.strftime("%Y-%m-%d")],
"tavg": [(row.tavg * 9/5 + 32)],
"tmin": [(row.tmin * 9/5 + 32)],
"tmax": [(row.tmax* 9/5 + 32)],
"prcp": [row.prcp * 0.0393701],
"wdir": [row.wdir],
"wspd": [row.wspd * 0.621371192],
"wpgt": [row.wpgt * 0.621371192],
"pres": [round(row.pres* 0.0145037738)],
"distance": [haversine(lat, lon, station_lat, station_lon)]
}
Can you share the result of print(f"Latitude: {latitude}, Longitude: {longitude}")
or the address?
-lat/lon of structure; structure_lat = 27.929571 structure_lon = -82.747118
-for the date range, September 9, 2022 thru September 27, 2022; start = datetime(2022, 9, 27) end = datetime(2022, 9, 29)
-This brings up weather stations; KCLW, KPIE, KTPA, KSPG, KMCF
However, it is not localized to only this lat/lon, all wpgt value for any station for any date range does not return values. When I use the UI on meteostat, the results also do not return wind gust as a visible output. Do you experience the same?
Hello world,
All of the values are returned except for "wpgt"... the one variable I need. Here is a working code. I'm stumped, hoping to receive some pointers.
Import meteostat: from meteostat import Stations, Daily, Point
Find nearby stations: stations = Stations() stations = stations.nearby(lat, lon, radius) stations = stations.fetch(num_stations)
Fetch daily data for each station: data_list = pd.DataFrame(columns=["station", "time", "tavg", "tmin","tmax","prcp","wdir","wspd","wpgt","pres",])
loop over each row in this set of data, add station, for each row for index, row in data.iterrows(): station_info = { "station": [station_id], "staion name": [station_name], "time": [index.strftime("%Y-%m-%d")], "tavg": [(row.tavg 9/5) + 32], "tmin": [(row.tmin 9/5) + 32], "tmax": [(row.tmax 9/5) + 32], "prcp": [row.prcp 0.0393701], "wdir": [row.wdir], "wspd": [row.wspd 0.621371192], "wpgt": [row.wpgt 0.621371192], "pres": [round(row.pres* 0.0145037738)]}
output_file_path = "FILE_NAME" output_file_path = "PATH" data_list.to_excel(output_file_path, index=False)