knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(lfcdata) library(dplyr)
Meteoland database offers access to the daily metereological interpolation data, powered by the meteoland package.
meteolanddb <- meteoland() meteolanddb
The Meteoland database has spatial precalculated data as rasters with a 1km
resolution, that can be accessed with the meteoland_get_lowres_raster
function:
This function allows to access the raster for a specified date (as character),
and returns a spatial object, whose class depends on the spatial argument.
Available classes are raster
(a RasterBrick object) and stars
(a stars object).
meteoland_get_lowres_raster( meteolanddb, date = as.character(Sys.Date() - 1), spatial = 'stars' )
meteoland_get_lowres_raster( meteolanddb, date = as.character(Sys.Date() - 1), spatial = 'raster' )
Dates available covers from 1976-01-01 to the day before current day.
meteoland_get_lowres_raster( meteolanddb, date = '1977-04-25', spatial = 'stars' )
It is possible to perform on-the-fly interpolation of meteorological variables
for a set of points, only for the current natural year (365 days). This is done
with the meteoland_points_interpolation
:
# points spatial object, obtained from fes database points_sf <- lfcdata::fes()$get_data('plot_nfi_4_results', spatial = TRUE) |> slice(1:5) meteoland_points_interpolation( meteolanddb, sf = points_sf, dates = c(as.character(Sys.Date() - 5), as.character(Sys.Date() - 1)) )
NOTE: This process may take a while depending on the number of points to interpolate
sf
must be an sf object containing POINT featuresdates
must be a vector of lenght 2, with the starting and the ending datepoints_id
is the name of the variable in sf identifying the points.For historic dates interpolation, only a lower resolution (1km) is available,
using the meteoland_historical_points_interpolation
function:
meteoland_historical_points_interpolation( meteolanddb, sf = points_sf, dates = c('1976-01-01', '1976-01-05'), points_id = 'plot_id' )
Arguments are the same as previously explained.
Interpolation for current and historical dates for polygons (not points) can
be done with the meteoland_raster_interpolation
. The returned value is a raster
with the interpolated data for the polygons provided.
# polygons object obtained from lidar database sf_polygons <- lfcdata::lidar()$get_data('lidar_municipalities', 'AB') |> slice(1:5) meteoland_raster_interpolation( meteolanddb, sf = sf_polygons, dates = c(as.character(Sys.Date() - 5), as.character(Sys.Date() - 1)) )
NOTE: This process may take a while depending on the number of points to interpolate
sf
must be an sf object containing POLYGON or MULTIPOLYGON featuresdates
must be a vector of length 2, with the starting and the ending datepoints_id
is the name of the variable in sf identifying the points.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.