Extending climaemet"

climaemet provides several functions for accessing a selection of endpoints of the AEMET API tool. However, this package does not cover in full all the capabilities of the API.

For that reason, we provide the get_data_aemet() function, that allows to access any API endpoint freely. The drawback is that the user would need to handle the results by him/herself.

library(climaemet)

Example: Normalized text

Some API endpoints, as predicciones-normalizadas-texto, provides the results as plain text on natural language. These results are not parsed by climaemet, but can be retrieved as this:

# endpoint, today forecast

today <- "/api/prediccion/nacional/hoy"

# Metadata
knitr::kable(get_metadata_aemet(today))

|unidad_generadora |descripcion |periodicidad |formato |copyright |notaLegal | |:-------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------|:-------------------------------------------------------------------------------------------------------|:----------------------------------| |Grupo Funcional de Predicción de Referencia |Predicción general nacional para hoy / mañana / pasado mañana / medio plazo (tercer y cuarto día) / tendencia (del quinto al noveno día) |Disponibilidad. Para hoy, solo se confecciona si hay cambios significativos. Para mañana y pasado mañana diaria a las 15:00 h.o.p.. Para el medio plazo diaria a las 16:00 h.o.p.. La tendencia, diaria a las 18:30 h.o.p. |ascii/txt |© AEMET. Autorizado el uso de la información y su reproducción citando a AEMET como autora de la misma. |https://www.aemet.es/es/nota_legal |

# Data
pred_today <- get_data_aemet(today)
#> 
#> Returning raw results. MIME type: text/plain
# Produce a result

clean <- gsub("\r", "\n", pred_today, fixed = TRUE)
clean <- gsub("\n\n\n", "\n", clean, fixed = TRUE)

cat(paste("---\n\n", clean, "\n---"))

AGENCIA ESTATAL DE METEOROLOGÍA PREDICCIÓN GENERAL PARA ESPAÑA DÍA 23 DE AGOSTO DE 2023 A LAS 08:21 HORA OFICIAL PREDICCIÓN VÁLIDA PARA EL MIÉRCOLES 23

A.- FENÓMENOS SIGNIFICATIVOS Temperaturas significativamente altas en gran parte del país. Posibilidad de alguna tormenta localmente fuerte en Pirineos. Intervalos de viento fuerte en el Estrecho.

B.- PREDICCIÓN En la mayor parte del país predominarán cielos poco nubosos o despejados con nubes altas, salvo nubes bajas matinales en litorales de Galicia, Cantábrico occidental, Estrecho, Melilla y Baleares. No se descarta alguna precipitación matinal en el norte de Galicia. Por la tarde abundante nubosidad de evolución en amplias zonas del tercio norte interior, con posibles chubascos y tormentas dispersos, más probables en montaña, en especial en el entorno de Pirineos, donde pueden ser localmente fuertes. En Canarias intervalos nubosos y abundante nubosidad media y alta, sin descartar algún chubasco o tormenta en las islas de mayor relieve.

Posibles bancos de nieblas matinales en litorales de Galicia, Cantábrico y Estrecho, así como calima alta en Canarias.

Temperaturas mínimas en aumento en el tercio noroeste peninsular y oeste de Andalucía. Máximas en aumento en el extremo norte, notable en el Cantábrico, incluso extraordinario en el País Vasco. Sin grandes cambios en el resto, se prevé alcanzar los 34-36 grados en prácticamente todo el interior peninsular y Baleares, incluso los 38-40 en gran parte de la vertiente atlántica, depresiones del nordeste y Cantábrico interior.

Levante en Alborán y, con intervalos fuertes, en el Estrecho. Viento del nordeste en los litorales del noroeste y sudeste. En el resto vientos flojos, de norte en Canarias, del sureste y sur en horas centrales gran parte del interior peninsular y variables en el resto.


Example: Maps

AEMET also provides map data, usually on image/gif format. One way to get this kind of data is as follows:

# Endpoint of a map
a_map <- "/api/mapasygraficos/analisis"

# Metadata
knitr::kable(get_metadata_aemet(a_map))

|unidad_generadora |descripción |periodicidad |formato |copyright |notaLegal | |:---------------------------------|:------------------------------------------|:-----------------------------------------------------------------------------------------|:---------|:-------------------------------------------------------------------------------------------------------|:----------------------------------| |Grupo Funcional de Jefes de Turno |Mapas de análisis de frentes en superficie |Dos veces al día, a las 02:00 y 14:00 h.o.p. en invierno y a las 03:00 y 15:00 en verano. |image/gif |© AEMET. Autorizado el uso de la información y su reproducción citando a AEMET como autora de la misma. |https://www.aemet.es/es/nota_legal |

the_map <- get_data_aemet(a_map)
#> 
#> Returning raw results. MIME type: image/gif


# Write as gif and include it
giffile <- "example-gif.gif"
writeBin(the_map, giffile)

# Display on the vignette
knitr::include_graphics(giffile)
Example: Surface analysis map provided by AEMET

Example: Surface analysis map provided by AEMET



Try the climaemet package in your browser

Any scripts or data that you put into this service are public.

climaemet documentation built on Aug. 30, 2023, 9:06 a.m.