Description Usage Arguments Details Value Note Examples
Initialise a TIN mesh object for use within TELEMAC.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
x |
Either: a |
... |
Arguments passed to or from other methods. If |
ikle |
If |
ipobo |
If |
s |
|
s_brk |
As |
a |
|
q |
|
If x
is a list
this function creates a Triangulated Irregular Network
(TIN) using function triangulate
. The following list
elements are required to perform the triangulation:
A matrix
, data.frame
, SpatialLines*
or sf
object
with two columns, each row defining a point along
the outer catchment boundary. Points are connected one-by-one to a line starting
with the first point, i.e. make sure points are in the right order! The first and
last point will be connected to close the boundary.
OPTIONAL, a matrix
, data.frame
, SpatialLines*
or sf
object with three columns
x
and y
, the x and y coordinates of vertices along the breaklines,
and line
, an identifier to identify individual breaklines.
An object of class t2d_tin
, which is a list with the following elements:
A matrix
with the x and y coordinates (as columns) of mesh points.
A matrix
with 3 columns of indices referring to rows in
points
; each row represents a mesh element (triangle).
A matrix
with 2 columns of indices referring to rows in
points
, the node points; each row represents an edge / segment of a triangle.
A vector
of indices referring to rows in points
, each
marking a point of the outer catchment boundary.
A matrix
with 2 columns of indices referring to rows in
points
, the vertices of the breaklines (used for mesh refinement during
triangulation).
Duplicated mesh points are silently removed.
Make sure breaklines do not intersect as this is not supported by the Triangle algorithm. A possible workaround to split intersecting breaklines in R using sf is shown in the examples.
If you want to construct a t2d_tin
object and get the error
Boundary points do not comply with requirements: [...]
the reason might be that breaklines are too close to the boundary causing that
points of the breaklines are used as boundary points which eventually results
in a discontinuous outer boundary. Try to increase the distance of breaklines
to the catchment boundary.
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 49 | ### BASIC FUNCTIONALITY ###
library(sf)
# load boundary as sf linestring
bnd <- st_read(system.file("dem/boundary_lagos.gpkg", package = "telemac"))
# create t2d_tin object
tin_obj <- tin(list(boundary = bnd), s = 90, a = 100^2, q = 30)
# inspection
tin_obj
str(tin_obj)
plot(tin_obj, pch = ".")
### DEALING WITH INTERSECTING BREAKLINES ###
library(sf)
library(tidyverse)
# example boundary and with intersecting breaklines
test_bnd <- st_linestring(
matrix(c(seq(0,100,5), rep(100,21), seq(100,0,-5), rep(0,21),
rep(0,21), seq(0,100,5), rep(100,21), seq(100,0,-5)),
ncol = 2)
) %>% st_sfc()
test_brk <- list(
st_linestring(matrix(c(seq(0,100,5), rep(50,21)), ncol = 2)),
st_linestring(matrix(c(rep(50,21), seq(0,100,5)), ncol = 2)),
st_linestring(matrix(c(seq(30,60,5), rep(60,11),
rep(20,7), seq(20,70,5)), ncol = 2))) %>% st_sfc()
# get intersection points and define buffer of 2 around these points
pt_inters <- c(test_bnd, test_brk) %>%
st_intersection() %>%
st_collection_extract(type = "POINT") %>%
st_buffer(2)
plot(test_bnd)
plot(test_brk, add = TRUE)
plot(pt_inters, add = TRUE)
# split breaklines
test_brk_unique <- st_difference(st_union(test_brk), st_union(pt_inters))
plot(test_bnd)
plot(test_brk_unique, add = TRUE)
# create mesh
tin_obj <- tin(list(boundary = test_bnd, breaklines = test_brk_unique),
s = 2, s_brk = 2, a = 4, q = 30)
plot(tin_obj, pch = ".")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.