View source: R/meteo_distance.R
meteo_nearby_stations | R Documentation |
This function inputs a dataframe with latitudes and longitudes of locations
and creates a dataframe with monitors within a certain radius of those
locations. The function can also be used, with the 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(),
var = "all",
year_min = NULL,
year_max = NULL,
radius = NULL,
limit = NULL
)
lat_lon_df |
A dataframe that contains the latitude, longitude, and
a unique identifier for each location ( |
lat_colname |
A character string giving the name of the latitude column
in the |
lon_colname |
A character string giving the name of the longitude column
in the |
station_data |
The output of |
var |
A character vector specifying either
A full list of possible weather variables is available in NOAA's README file for the GHCND data (https://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. |
year_min |
A numeric value giving the earliest year from which you ultimately want weather data (e.g., 2013, if you only are interested in data from 2013 and later). |
year_max |
A numeric value giving the latest year from which you ultimately want weather data. |
radius |
A numeric vector giving the radius (in kilometers) within which to search for monitors near a location. |
limit |
An integer giving the maximum number of monitors to include for
each location. The |
Great circle distance is used to determine whether a weather monitor is within the required radius.
A list containing dataframes with the sets of unique weather stations within the search radius for each location. Site IDs for the weather stations given in this dataframe can be used in conjunction with other functions in the 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.
By default, this function will pull the full station list from NOAA
to use to identify nearby locations. If you will be creating lists of
monitors nearby several stations, you can save some time by using the
ghcnd_stations()
function separately to create an object
with all stations and then use the argument station_data
in
this function to reference that object, rather than using this function's
defaults (see examples).
Alex Simmons a2.simmons@qut.edu.au, Brooke Anderson brooke.anderson@colostate.edu
The weather monitor IDs generated by this function can be used in
other functions in the 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() # 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.