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
)

Arguments

country

country name (e.g., "SRI LANKA"). Single entries allowed only.

date

optionally, a day when measurements were done in all available locations; current Sys.Date used by default

add_map

logical - whether to draw a map for a returned data frame (requires maps/mapdata packages)

point

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.

no_of_stations

how many nearest stations will be returned from the given geographical coordinates; default 30

allow_failure

logical - whether to allow or stop on failure. By default set to TRUE. For debugging purposes change to FALSE

Value

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.

Examples

# \donttest{
  nearest_stations_noaa(country = "SRI LANKA", 
  point = c(80, 6),
  add_map = TRUE, 
  no_of_stations = 10)
#> /tmp/RtmpWCv8r5/file15e844615f0b

#>      CTRY countries   USAF  WBAN              STATION.NAME STATE ICAO   LAT
#> 6052   CE SRI LANKA 434950 99999                     GALLE            6.033
#> 6063   CE SRI LANKA 434860 99999                 RATNAPURA            6.683
#> 6055   CE SRI LANKA 434670 99999         COLOMBO RATMALANA       VCCC 6.822
#> 6059   CE SRI LANKA 434660 99999                   COLOMBO            6.900
#> 6049   CE SRI LANKA 434970 99999                HAMBANTOTA       VCRI 6.117
#> 6062   CE SRI LANKA 434500 99999 BANDARANAIKE INTL COLOMBO       VCBI 7.181
#> 6064   CE SRI LANKA 434730 99999              NUWARA ELIYA            6.967
#> 6043   CE SRI LANKA 434760 99999                DIYATALAWA            6.817
#> 6053   CE SRI LANKA 434790 99999                   BADULLA            6.983
#> 6054   CE SRI LANKA 434440 99999                     KANDY            7.333
#>         LON ELEV.M.    BEGIN      END Begin_date   End_date  distance
#> 6052 80.217    13.0 20020116 20240922 2002-01-16 2024-09-22  24.62659
#> 6063 80.400    88.0 20020116 20241002 2002-01-16 2024-10-02  88.80485
#> 6055 79.886     6.7 19440513 20241014 1944-05-13 2024-10-14  93.10837
#> 6059 79.867     7.0 19440101 20241007 1944-01-01 2024-10-07 102.07363
#> 6049 81.133    20.0 19450801 20241014 1945-08-01 2024-10-14 127.79482
#> 6062 79.866     8.8 19620101 20241014 1962-01-01 2024-10-14 133.35446
#> 6064 80.767  1880.0 19570701 20241001 1957-07-01 2024-10-01 138.47897
#> 6043 80.967  1250.0 20050714 20241007 2005-07-14 2024-10-07 142.03310
#> 6053 81.050   667.0 20030112 20240917 2003-01-12 2024-09-17 161.37568
#> 6054 80.633   477.0 20030111 20240921 2003-01-11 2024-09-21 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/RtmpWCv8r5/file15e8246bfec9

# }