Description Usage Arguments Value Note Examples
Initialise a mesh (geometry) object for use within TELEMAC.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | geo(x, fname, ...)
## S3 method for class 'character'
geo(x, fname = NULL, ...)
## S3 method for class 'list'
geo(x, fname = NULL, ...)
## S3 method for class 't2d_geo'
geo(x, fname = NULL, data = NULL, ...)
## S3 method for class 't2d_tin'
geo(x, fname = NULL, ..., dem, title = "")
## S3 method for class 't2d_geo'
print(x, ...)
|
x |
Either: A |
fname |
|
... |
Arguments passed to or from other methods: |
data |
|
dem |
If |
title |
|
An object of class t2d_geo
consisting of an attribute file
pointing to a specific geometry file and a list
with the following elements:
General mesh information including title, precision (of numbers in the slf file in bytes), the numbers of mesh elements and points, and the number of points per mesh (3 in case of triangles which is the only supported value for now).
A mesh object of class t2d_tin
, see tin.
Values of mesh point elevations.
A named list
of additional, in TELEMAC termed 'private'
variables with elements values
and unit
.
Also note the associated plot.t2d_geo
method.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ## Not run:
library(raster)
library(sf)
library(tidyverse)
# get a tin
bnd <- st_read(system.file("dem/boundary_lagos.gpkg", package = "telemac"))
tin_obj <- tin(list(boundary = bnd), s = 90, a = 100^2, q = 30)
# load raster
dem_rast <- raster(system.file("dem/dem_merit_lagos.tif", package = "telemac"))
# create a geo object (interpolates raster to mesh points)
geo_obj <- geo(tin_obj, dem = dem_rast)
geo_obj
str(geo_obj)
# adjust file name
geo_obj <- geo(geo_obj, fname = "geo.slf")
geo_obj
# plot: mesh elevations interpolated to grid with resolution s
plot(geo_obj, s = 30)
# add additional private variable (in this case Curve Numbers)
dem_priv <- list(
# mandatory 'elevation' as raster object
elevation = dem_rast,
# additional variable 'cn' as (in this case) data.frame
cn = list(values = as.data.frame(dem_rast, xy = TRUE, na.rm = TRUE) %>%
select(x, y) %>%
mutate(z = case_when(
y > 740000 ~ 95,
x > 534000 ~ 90,
(x <= 534000) & (y <= 740000) ~ 80
)),
unit = "-",
# nearest-neighbour interpolation of CN values
pars_interp = list(n = 1))
)
geo_priv <- geo(tin_obj, dem = dem_priv)
geo_priv
str(geo_priv)
plot(geo_priv, s = 30, v = "cn")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.