sl.contours: Compute Contours

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/sl.contours.R

Description

Compute contour lines of a 2-dimensional field on an unstructured triangular mesh on a sphere.

Usage

1
sl.contours(var = NULL, var.nc = NULL, varid = NULL, levels = 0, neighmat = NULL, lat, lon, elem, CDOgriddes = NULL, verbose = FALSE)

Arguments

var

a numeric vector of length N resembling a 2-dimensional field on an unstructured mesh on a sphere.

var.nc

a character providing the system location of a NetCDF file containing the field to be analysed. Used only if var is not specified.

varid

a character providing the name of the variable in var.nc to be used. Used only if var is not specified.

levels

a vector providing the values for which contour lines shall be computed.

neighmat

an NxM matrix providing the neighbour nodes of each node (point) in var (or var.nc). If not provided, this matrix is computed using sl.findneighbours based on elem.

lat

a numeric vector of length N providing the latitudes of each node (point) in var (or var.nc).

lon

a numeric vector of length N providing the latitudes of each node (point) in var (or var.nc).

elem

an Nex3 matrix providing the vertex indices of each triangular element spanned by the nodes (points) in var (or var.nc). Note that Ne ~= 2xN.

verbose

a logical value specifiying whether additional statements shall be printed to document progress. Default is FALSE.

Details

The algorithm implemented here does not work element-wise, but builds up contiguous contour segments step by step. Note that a linear evolution of the field on the elements (triangles) between the nodes is assumed.

Value

A list with one element for each level. Each of these is another list with the following elements:

level

a scalar giving the level of the contour.

segments

a list of lists for each segment with elements lat (vector with latitudes of the points forming the segment), lon (vector with longitudes of the points forming the segment), and length (scalar giving the length of the segment).

length

a scalar giving the length of the contour, summing all segments.

Note

It is planned to extend this algorithm such that it works with any unstructured mesh based on polygons with any number of vertices. One simple way to achieve this would be to add a step at the beginning where any polygon with more than 3 vertices is decomposed into triangles, e.g. with a central reference point based on the polygon centroid.

Author(s)

Helge Goessling

Examples

1
## Example to be provided ...

helgegoessling/spheRlab documentation built on Sept. 29, 2017, 6:36 a.m.