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/Rtmpaz3JGC/file1ec9555b6d33

#>      CTRY countries   USAF  WBAN              STATION.NAME STATE ICAO   LAT
#> 6050   CE SRI LANKA 434950 99999                     GALLE            6.033
#> 6046   CE SRI LANKA 434860 99999                 RATNAPURA            6.683
#> 6040   CE SRI LANKA 434670 99999         COLOMBO RATMALANA       VCCC 6.822
#> 6035   CE SRI LANKA 434660 99999                   COLOMBO            6.900
#> 6047   CE SRI LANKA 434970 99999                HAMBANTOTA       VCRI 6.117
#> 6036   CE SRI LANKA 434500 99999 BANDARANAIKE INTL COLOMBO       VCBI 7.181
#> 6048   CE SRI LANKA 434730 99999              NUWARA ELIYA            6.967
#> 6045   CE SRI LANKA 434760 99999                DIYATALAWA            6.817
#> 6043   CE SRI LANKA 434790 99999                   BADULLA            6.983
#> 6033   CE SRI LANKA 434440 99999                     KANDY            7.333
#>         LON ELEV.M.    BEGIN      END Begin_date   End_date  distance
#> 6050 80.217    13.0 20020116 20250824 2002-01-16 2025-08-24  24.62659
#> 6046 80.400    88.0 20020116 20250824 2002-01-16 2025-08-24  88.80485
#> 6040 79.886     6.7 19440513 20250824 1944-05-13 2025-08-24  93.10837
#> 6035 79.867     7.0 19440101 20250824 1944-01-01 2025-08-24 102.07363
#> 6047 81.133    20.0 19450801 20250824 1945-08-01 2025-08-24 127.79482
#> 6036 79.866     8.8 19620101 20250824 1962-01-01 2025-08-24 133.35446
#> 6048 80.767  1880.0 19570701 20250824 1957-07-01 2025-08-24 138.47897
#> 6045 80.967  1250.0 20050714 20250824 2005-07-14 2025-08-24 142.03310
#> 6043 81.050   667.0 20030112 20250824 2003-01-12 2025-08-24 161.37568
#> 6033 80.633   477.0 20030111 20250824 2003-01-11 2025-08-24 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/Rtmpaz3JGC/file1ec96bc72f3f

# }