geo: Mesh / geometry object

Description Usage Arguments Value Note Examples

View source: R/geometry.R

Description

Initialise a mesh (geometry) object for use within TELEMAC.

Usage

 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, ...)

Arguments

x

Either: A character string providing the name of an existing geometry file; a list with all required elements (see 'Value'); an object of class t2d_geo; an object of class t2d_tin (requires input dem).

fname

character, name for the associated geometry file (can also be used to replace an existing entry).

...

Arguments passed to or from other methods: read_geo if x is a file name or interpol if x is a t2d_tin object.

data

list with all required elements (see Value) that can be given to update an existing object x.

dem

If x is of type t2d_tin: a single DEM or a named list with element elevation and further private variables from which the values will be interpolated to the TIN mesh points. Each element will be forwarded to interpol, argument src (see descriptions therein for supported types). Private variables must be a list with elements values (the object passed to interpol), pars_interp (variable-specific parameter list passed to interpol with priority over ...), and unit (the unit of the variable). Parameters for interpolation include, e.g., the number of neighbours n, etc.

title

character, mesh title (not necessary, max. 72 characters).

Value

An object of class t2d_geo consisting of an attribute file pointing to a specific geometry file and a list with the following elements:

header

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).

tin

A mesh object of class t2d_tin, see tin.

elevation

Values of mesh point elevations.

privars

A named list of additional, in TELEMAC termed 'private' variables with elements values and unit.

Note

Also note the associated plot.t2d_geo method.

Examples

 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)

tpilz/telemac documentation built on Feb. 10, 2022, 2:12 p.m.