R/nearest_stations_noaa.R
nearest_stations_noaa.Rd
Returns a data frame of meteorological stations with their coordinates and distance from a given location based on the noaa website. The returned list is valid only for a given day.
nearest_stations_noaa(
country,
date = Sys.Date(),
add_map = TRUE,
point = NULL,
no_of_stations = 10,
allow_failure = TRUE
)
country name (e.g., "SRI LANKA"). Single entries allowed only.
optionally, a day when measurements were done in all available locations; current Sys.Date used by default
logical - whether to draw a map for a returned data frame (requires maps/mapdata packages)
a vector of two coordinates (longitude, latitude) for a point we want to find nearest stations to (e.g. c(80, 6)). If not provided the query will be based on a mean longitude and latitude among available dataset.
how many nearest stations will be returned from the given geographical coordinates; default 30
logical - whether to allow or stop on failure. By default set to TRUE. For debugging purposes change to FALSE
A data.frame with number of nearest station according to given point columns describing stations parameters
(e.g. ID station, distance from point, geographic coordinates, etc.) where each row represent a measurement,
each station which has a measurements on selected date. If add_map = TRUE
additional map of downloaded data is added.
# \donttest{
nearest_stations_noaa(country = "SRI LANKA",
point = c(80, 6),
add_map = TRUE,
no_of_stations = 10)
#> /tmp/Rtmp2Ayl9k/file1ccb2d09f9a6
#> CTRY countries USAF WBAN STATION.NAME STATE ICAO LAT
#> 6056 CE SRI LANKA 434950 99999 GALLE 6.033
#> 6046 CE SRI LANKA 434860 99999 RATNAPURA 6.683
#> 6059 CE SRI LANKA 434670 99999 COLOMBO RATMALANA VCCC 6.822
#> 6050 CE SRI LANKA 434660 99999 COLOMBO 6.900
#> 6053 CE SRI LANKA 434970 99999 HAMBANTOTA VCRI 6.117
#> 6052 CE SRI LANKA 434500 99999 BANDARANAIKE INTL COLOMBO VCBI 7.181
#> 6057 CE SRI LANKA 434730 99999 NUWARA ELIYA 6.967
#> 6064 CE SRI LANKA 434760 99999 DIYATALAWA 6.817
#> 6063 CE SRI LANKA 434790 99999 BADULLA 6.983
#> 6062 CE SRI LANKA 434440 99999 KANDY 7.333
#> LON ELEV.M. BEGIN END Begin_date End_date distance
#> 6056 80.217 13.0 20020116 20250304 2002-01-16 2025-03-04 24.62659
#> 6046 80.400 88.0 20020116 20250304 2002-01-16 2025-03-04 88.80485
#> 6059 79.886 6.7 19440513 20250304 1944-05-13 2025-03-04 93.10837
#> 6050 79.867 7.0 19440101 20250304 1944-01-01 2025-03-04 102.07363
#> 6053 81.133 20.0 19450801 20250304 1945-08-01 2025-03-04 127.79482
#> 6052 79.866 8.8 19620101 20250304 1962-01-01 2025-03-04 133.35446
#> 6057 80.767 1880.0 19570701 20250304 1957-07-01 2025-03-04 138.47897
#> 6064 80.967 1250.0 20050714 20250304 2005-07-14 2025-03-04 142.03310
#> 6063 81.050 667.0 20030112 20250304 2003-01-12 2025-03-04 161.37568
#> 6062 80.633 477.0 20030111 20250304 2003-01-11 2025-03-04 165.56435
uk_stations = nearest_stations_noaa(country = "UNITED KINGDOM", no_of_stations = 100)
#> The point argument should have two coordinates.
#> We will provide nearest stations for mean location.
#> To change it please change the `point` argument c(LON,LAT)
#> /tmp/Rtmp2Ayl9k/file1ccb5b2f6d0b
# }