--- title: "Extending climaemet" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Extending climaemet} %\VignetteEncoding{UTF-8} %\VignetteEngine{knitr::rmarkdown} resource_files: - vignettes/example-gif.gif --- **climaemet** provides several functions for accessing a selection of endpoints of the [AEMET API tool](https://opendata.aemet.es/dist/index.html?). 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. ```r 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: ```r # 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 | ```r # Data pred_today <- get_data_aemet(today) #> #> Returning raw results. MIME type: text/plain ``` ```r # 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 10 DE SEPTIEMBRE DE 2023 A LAS 09:53 HORA OFICIAL PREDICCIÓN VÁLIDA PARA EL DOMINGO 10 A.- FENÓMENOS SIGNIFICATIVOS Chubascos y tormentas localmente fuertes en áreas de la mitad norte y zona centro peninsular. B.- PREDICCIÓN Se prevén cielos nubosos o con intervalos nubosos y nubosidad de evolución, con posibilidad de chubascos y tormentas, excepto en el extremo suroeste y litoral mediterráneo, donde sólo habrá intervalos nubosos. Pueden ser localmente fuertes en áreas de la mitad norte y zona centro. Poco nuboso en Baleares. Intervalos nubosos en Canarias, con probabilidad de chubascos débiles ocasionales en las islas montañosas. Probabilidad de bancos de niebla matinales en el área mediterránea y litoral atlántico andaluz. Temperaturas máximas en descenso en el extremo norte peninsular, y sin grandes cambios en el resto y en las mínimas. Viento del sur en la costa oeste de Galicia, y del este en el área mediterránea. Flojo variable 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: ```r # 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 | ```r 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