limit
argument, to pull
a certain number of the closest weather monitors to each location.
The weather monitor IDs in the output dataframe can be used with other
rnoaa
functions to pull data from all available weather stations near
a location (e.g., meteo_pull_monitors
).
meteo_nearby_stations(lat_lon_df, lat_colname = "latitude", lon_colname = "longitude", station_data = ghcnd_stations()[[1]], var = "all", year_min = NULL, year_max = NULL, radius = NULL, limit = NULL)
id
). For an example of the
proper format for this dataframe, see the examples below. Latitude and
longitude must both be in units of decimal degrees. Southern latitudes
and Western longitudes should be given as negative values.lat_lon_df
dataframe.lat_lon_df
dataframe.ghcnd_stations()[[1]]
, which is
a current list of weather stations available through NOAA for the GHCND
dataset. The format of this is a dataframe
with one row per weather station. Latitude and longitude for the station
locations should be in columns with the names "latitude" and "longitude",
consistent with the output from ghcnd_stations()[[1]]
. To save time, run the
ghcnd_stations
call and save the output to an object, rather than
rerunning the default every time (see the examples in
meteo_nearby_stations
)."all"
(pull all
available weather parameters for the site) or the weather parameters to
keep in the final data (e.g., c("TMAX", "TMIN")
to only keep
maximum and minimum temperature). Example choices for this argument include:
PRCP
: Precipitation, in tenths of millimeters
TAVG
: Average temperature, in tenths of degrees Celsius
TMAX
: Maximum temperature, in tenths of degrees Celsius
TMIN
: Minimum temperature, in tenths of degrees Celsius
A full list of possible weather variables is available in NOAA's README file for the GHCND data (http://www1.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt). Most weather stations will only have a small subset of all the possible weather variables, so the data generated by this function may not include all of the variables the user specifies through this argument.
rnoaa
package to pull weather data for the station. The dataframe
for each location includes:
id
: The weather station ID, which can be used in other
functions to pull weather data from the station;
name
: The weather station name;
latitude
: The station's latitude, in decimal degrees. Southern
latitudes will be negative;
longitude
: The station's longitude, in decimal degrees. Western
longitudes will be negative;
distance
: The station's distance, in kilometers, from the
location.
rnoaa
package, like
meteo_pull_monitors
and meteo_tidy_ghcnd
, to
pull weather data from weather monitors near a location.
## Not run:
#
# station_data <- ghcnd_stations()[[1]] # Takes a while to run
#
# lat_lon_df <- data.frame(id = c("sydney", "brisbane"),
# latitude = c(-33.8675, -27.4710),
# longitude = c(151.2070, 153.0234))
# nearby_stations <- meteo_nearby_stations(lat_lon_df = lat_lon_df,
# station_data = station_data, radius = 10)
#
# miami <- data.frame(id = "miami", latitude = 25.7617, longitude = -80.1918)
#
# # Get all stations within 50 kilometers
# meteo_nearby_stations(lat_lon_df = miami, station_data = station_data,
# radius = 50, var = c("PRCP", "TMAX"),
# year_min = 1992, year_max = 1992)
# # Get the closest 10 monitors
# meteo_nearby_stations(lat_lon_df = miami, station_data = station_data,
# limit = 10, var = c("PRCP", "TMAX"),
# year_min = 1992, year_max = 1992)
# ## End(Not run)
Run the code above in your browser using DataLab