Getting Started With riweather
¶
Suppose you need weather data at a certain site. To list all weather stations in order of their distance to that site, use riweather.rank_stations()
.
This gives us the name and USAF identifiers of all ISD weather stations in the United States, along with their latitudes and longitudes and their distances (in meters) to the target site. The “years” column is a list of years for which there is available weather data from that station. The “quality” column contains the quality of the data file for the corresponding year—this is based on the number of observations in the file.
You probably don’t want all three thousand weather stations that are returned, so let’s be more efficient and limit our search to stations that have data for 2022 and stations that are within 20 km.
Select the closest station, Erie Municipal Airport, using riweather.select_station()
.
Let’s see how complete we can expect the data to be when we pull it by looking at the quality report.
The data for 2022 is "high"
quality, with more than 2,000 observations in each month. Assuming they are evenly spaced, that corresponds to one observation roughly every 20 minutes.
Now we can use the Station.fetch_temp_data()
method to get temperature data in degrees Fahrenheit.
It’s important to note that the timestamps are always in UTC. The temperature data is hourly by default, but riweather
can resample it to a different frequency as well.
We can verify the location of our site and the nearest weather stations by plotting them on a map with riweather.plot_stations()
.
Only have a ZIP code for your site and not a precise latitude and longitude? No problem. You can use riweather.zcta_to_lat_lon()
to get an approximate location.