Description Usage Arguments Value Note Examples
Linearly interpolates the values of a mesh based on irregular triangles to a regular grid.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | tin2grid(x, s, output, ...)
## S3 method for class 'data.frame'
tin2grid(
x,
s,
output = c("data.frame", "list", "raster"),
...,
col_x = "x",
col_y = "y",
col_z = "z",
tinmat
)
## S3 method for class 't2d_geo'
tin2grid(
x,
s,
output = c("data.frame", "list", "raster"),
...,
v = "elevation"
)
## S3 method for class 't2d_res'
tin2grid(
x,
s,
output = c("data.frame", "list", "raster"),
...,
v = NULL,
t = NULL
)
|
x |
Either: a |
s |
|
output |
|
... |
Arguments passed to or from other methods. |
col_x |
If |
col_y |
If |
col_z |
If |
tinmat |
|
v |
|
t |
|
If output == "data.frame": A data.frame with:
col_xX coordinates of the output grid
col_yY coordinates of the output grid
col_zInterpolated values
OPTIONAL (more than one given): imported variable the current values refer to
OPTIONAL (more than one given): simulation timestep the current values refer to
If output == "list": A list with:
X coordinates of the output grid
Y coordinates of the output grid
Matrix with interpolated values, where z[i,j] points to coordinates x[i] and y[j]
If output == "raster": An object of class raster.
If you import many variables or timesteps or the mesh is huge or s very small
the resulting dataset might become excessively large (especially if output is a
data.frame)!
If x is a data.frame, all input arguments referring to columns
of x support quasiquotation, i.e. they can be specified by
their names, quoted or unquoted, or as column position.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # plot model bathymetry with ggplot
library(raster)
library(sf)
library(tidyverse)
# t2d_geo object
bnd <- st_read(system.file("dem/boundary_lagos.gpkg", package = "telemac"))
tin_obj <- tin(list(boundary = bnd), s = 90, a = 100^2, q = 30)
dem_rast <- raster(system.file("dem/dem_merit_lagos.tif", package = "telemac"))
geo_obj <- geo(tin_obj, dem = dem_rast)
# interpolate to regular grid as df and plot
geo_df <- tin2grid(geo_obj, s = 90, output = "data.frame")
ggplot(geo_df, aes(x = x, y = y, fill = value)) +
geom_raster() +
coord_equal() +
scale_fill_viridis_c()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.