Skip to contents

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 or FALSE. Should the function return an sf spatial object? If FALSE (the default value) it returns a tibble. Note that you need to have the sf package installed.

extract_metadata

Logical TRUE/FALSE. On TRUE the output is a tibble with the description of the fields. See also get_metadata_aemet().

progress

Logical, display a cli::cli_progress_bar() object. If verbose = TRUE won't be displayed.

Value

A tibble or a sf object.

API Key

You need to set your API Key globally using aemet_api_key().

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)
glimpse(forecast_b)
#> Rows: 6
#> Columns: 36
#> $ elaborado                <dttm> 2025-01-08 09:00:22, 2025-01-08 09:00:22, 20…
#> $ id                       <chr> "0704001", "0704001", "0704001", "0704007", "…
#> $ localidad                <chr> "07040", "07040", "07040", "07040", "07040", …
#> $ fecha                    <date> 2025-01-08, 2025-01-09, 2025-01-10, 2025-01-…
#> $ nombre                   <chr> "Cala Major", "Cala Major", "Cala Major", "Pl…
#> $ estadoCielo_value        <lgl> NA, NA, NA, NA, NA, NA
#> $ estadoCielo_f1           <int> 100, 100, 100, 100, 100, 100
#> $ estadoCielo_descripcion1 <chr> "despejado", "despejado", "despejado", "despe…
#> $ estadoCielo_f2           <int> 120, 100, 120, 120, 100, 110
#> $ estadoCielo_descripcion2 <chr> "muy nuboso", "despejado", "muy nuboso", "muy…
#> $ viento_value             <lgl> NA, NA, NA, NA, NA, NA
#> $ viento_f1                <int> 220, 220, 210, 220, 220, 210
#> $ viento_descripcion1      <chr> "moderado", "moderado", "flojo", "moderado", …
#> $ viento_f2                <int> 220, 220, 210, 220, 220, 210
#> $ viento_descripcion2      <chr> "moderado", "moderado", "flojo", "moderado", …
#> $ oleaje_value             <lgl> NA, NA, NA, NA, NA, NA
#> $ oleaje_f1                <int> 320, 310, 310, 320, 320, 320
#> $ oleaje_descripcion1      <chr> "moderado", "débil", "débil", "moderado", "mo…
#> $ oleaje_f2                <int> 320, 320, 310, 330, 320, 320
#> $ oleaje_descripcion2      <chr> "moderado", "moderado", "débil", "fuerte", "m…
#> $ tMaxima_value            <lgl> NA, NA, NA, NA, NA, NA
#> $ tMaxima_valor1           <int> 19, 19, 19, 18, 19, 19
#> $ sTermica_value           <lgl> NA, NA, NA, NA, NA, NA
#> $ sTermica_valor1          <int> 440, 440, 440, 440, 440, 450
#> $ sTermica_descripcion1    <chr> "fresco", "fresco", "fresco", "fresco", "fres…
#> $ tAgua_value              <lgl> NA, NA, NA, NA, NA, NA
#> $ tAgua_valor1             <int> 17, 16, 16, 18, 17, 17
#> $ uvMax_value              <lgl> NA, NA, NA, NA, NA, NA
#> $ uvMax_valor1             <int> 2, 1, 2, 2, 1, 2
#> $ tmaxima_value            <lgl> NA, NA, NA, NA, NA, NA
#> $ tmaxima_valor1           <int> 19, 19, 19, 18, 19, 19
#> $ stermica_value           <lgl> NA, NA, NA, NA, NA, NA
#> $ stermica_valor1          <int> 440, 440, 440, 440, 440, 450
#> $ stermica_descripcion1    <chr> "fresco", "fresco", "fresco", "fresco", "fres…
#> $ tagua_value              <lgl> NA, NA, NA, NA, NA, NA
#> $ tagua_valor1             <int> 17, 16, 16, 18, 17, 17

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"
  )