Get a database of daily weather forecasts for a beach. Beach database can
be accessed with aemet_beaches()
.
Usage
aemet_forecast_beaches(
x,
verbose = FALSE,
return_sf = FALSE,
extract_metadata = FALSE,
progress = TRUE
)
Arguments
- x
A vector of beaches codes to extract. See
aemet_beaches()
.- verbose
Logical
TRUE/FALSE
. Provides information about the flow of information between the client and server.- return_sf
Logical
TRUE
orFALSE
. Should the function return ansf
spatial object? IfFALSE
(the default value) it returns atibble
. Note that you need to have the sf package installed.- extract_metadata
Logical
TRUE/FALSE
. OnTRUE
the output is atibble
with the description of the fields. See alsoget_metadata_aemet()
.- progress
Logical, display a
cli::cli_progress_bar()
object. Ifverbose = TRUE
won't be displayed.
API Key
You need to set your API Key globally using aemet_api_key()
.
See also
aemet_beaches()
for beaches codes.
Other aemet_api_data:
aemet_alert_zones()
,
aemet_alerts()
,
aemet_beaches()
,
aemet_daily_clim()
,
aemet_extremes_clim()
,
aemet_forecast_daily()
,
aemet_forecast_fires()
,
aemet_last_obs()
,
aemet_monthly
,
aemet_normal
,
aemet_stations()
Other forecasts:
aemet_forecast_daily()
,
aemet_forecast_fires()
,
aemet_forecast_tidy()
Examples
# Forecast for beaches in Palma, Mallorca
library(dplyr)
library(ggplot2)
palma_b <- aemet_beaches() %>%
filter(ID_MUNICIPIO == "07040")
forecast_b <- aemet_forecast_beaches(palma_b$ID_PLAYA)
#>
#> AEMET API call for '0704001' returned an error
#> Return NULL for this query
glimpse(forecast_b)
#> Rows: 3
#> Columns: 36
#> $ elaborado <dttm> 2025-04-02 08:50:17, 2025-04-02 08:50:17, 20…
#> $ id <chr> "0704007", "0704007", "0704007"
#> $ localidad <chr> "07040", "07040", "07040"
#> $ fecha <date> 2025-04-02, 2025-04-03, 2025-04-04
#> $ nombre <chr> "Playa de Palma", "Playa de Palma", "Playa de…
#> $ estadoCielo_value <lgl> NA, NA, NA
#> $ estadoCielo_f1 <int> 120, 110, 120
#> $ estadoCielo_descripcion1 <chr> "muy nuboso", "nuboso", "muy nuboso"
#> $ estadoCielo_f2 <int> 120, 120, 100
#> $ estadoCielo_descripcion2 <chr> "muy nuboso", "muy nuboso", "despejado"
#> $ viento_value <lgl> NA, NA, NA
#> $ viento_f1 <int> 220, 220, 220
#> $ viento_descripcion1 <chr> "moderado", "moderado", "moderado"
#> $ viento_f2 <int> 220, 220, 220
#> $ viento_descripcion2 <chr> "moderado", "moderado", "moderado"
#> $ oleaje_value <lgl> NA, NA, NA
#> $ oleaje_f1 <int> 310, 310, 310
#> $ oleaje_descripcion1 <chr> "débil", "débil", "débil"
#> $ oleaje_f2 <int> 310, 310, 310
#> $ oleaje_descripcion2 <chr> "débil", "débil", "débil"
#> $ tMaxima_value <lgl> NA, NA, NA
#> $ tMaxima_valor1 <int> 20, 22, 23
#> $ sTermica_value <lgl> NA, NA, NA
#> $ sTermica_valor1 <int> 440, 450, 450
#> $ sTermica_descripcion1 <chr> "fresco", "suave", "suave"
#> $ tAgua_value <lgl> NA, NA, NA
#> $ tAgua_valor1 <int> 16, 16, 16
#> $ uvMax_value <lgl> NA, NA, NA
#> $ uvMax_valor1 <int> 6, 6, 5
#> $ tmaxima_value <lgl> NA, NA, NA
#> $ tmaxima_valor1 <int> 20, 22, 23
#> $ stermica_value <lgl> NA, NA, NA
#> $ stermica_valor1 <int> 440, 450, 450
#> $ stermica_descripcion1 <chr> "fresco", "suave", "suave"
#> $ tagua_value <lgl> NA, NA, NA
#> $ tagua_valor1 <int> 16, 16, 16
ggplot(forecast_b) +
geom_line(aes(fecha, tagua_valor1, color = nombre)) +
facet_wrap(~nombre, ncol = 1) +
labs(
title = "Water temperature in beaches of Palma (ES)",
subtitle = "Forecast 3-days",
x = "Date",
y = "Temperature (Celsius)",
color = "Beach"
)