trigrid() creates a triangular grid based on the
tessellation of an icosahedron.
Arguments
- tessellation
(
numeric) An integer vector with the tessellation values. Each number describes the number of new edges replacing one original edge. Multiple series of tessellations are possible this way. The total tessellation is the product of the tessellation vector. Higher values result in more uniform cell sizes, but the larger number of tessellation series increases the speed of lookup functions.- deg
(
numeric) The target edge length of the grid in degrees. If provided, the function will select the appropriate tessellation vector from thetriguide-table, which is closest to the target. Note that these are unlikely to be the exact matches.- spacing
(
numeric) The target spacing of the grid in degrees. If provided, the function will select the appropriate tessellation vector from thetriguide-table, which is closest to the target. Note that these are unlikely to be the exact matches.- sp
(
logical) Flag indicating whether theSpatialPolygonsclass representation of the grid should be added to the object when the grid is calculated. If set toTRUEtheSpPolygons()function will be run with with the resolution parameter set to 25. The resulting object will be stored in slot@sp. As the calculation of this object can substantially increase the grid creation time, by default this argument has a value ofFALSE. TheSpatialPolygonsclass representation can be added on demand by running the functionnewsp.- graph
(
logical) Flag indicating whether the'igraph'class representation of the grid should be added to the object when the grid is calculated. This argument defaults toTRUEbecause this option has only minor performance load on the grid constructor function. For familiarization with the object structure, however, setting this parameter toFALSEmight help, as invokingstron the'igraph'class slot of the class might flood the console.- radius
(
numeric) The radius of the grid. Defaults to the authalic radius of Earth.- center
(
numeric) The origin of the grid in the reference Cartesian coordinate system. Defaults to (0,0,0).- verbose
(
logical) Should messages be printed during grid creation?
Details
The grid structure functions as a frame for data graining, plotting and spatial
calculations. Data can be stored in layers that are linked to the grid object. In the current version only the
facelayer class is implemented, which allows the user to render data to the cells
of the grid, which are usually referred to as faces.
The grid 'user interface' is made up of four primary tables: the @vertices table for the coordinates of the vertices,
the faceCenters for the coordinates of the centers of faces,
the faces and the edges tables that contain which vertices form which faces and edges respectively.
In these tables, the faces and vertices are sorted to form spirals that go from the north pole in a counter-clockwise
direction. In case grid subsetting is performed these tables get truncated.
At finer resolutions, the large number of spatial elements render all calculations resource demanding and slow,
therefore the hierarchical structure created during the tessellation procedure is retained for efficient implementation.
These data are stored in a list in the slot @skeleton and are 0-indexed integer tables for Rccp-based functions. $v
stores vertex, $f the edge, and $e contains the edge data for plotting and calculations. In these tables
the original hierarchy based orderings of the units are retained, during subsetting, additional vectors are used to indicate
deactivation of these units. Any sort of meddling with the @skeleton object will lead to unexpected behavior.
Slots
verticesMatrix of the vertex XYZ coordinates.
facesMatrix of the verticies forming the faces.
edgesMatrix of the vertices forming the edges.
tessellationContains the tessellation vector.
orientationContains the grid orientation in xyz 3d space, values in radian relative to the (0,1,0) direction.
centeris the xyz coordinates of the grids origin/center.
divvector contains the number of faces that a single face of the previous tessellation level is decomposed to.
faceCenterscontains the xyz coordinates of the centers of the faces on the surface of the sphere.
beltsVector of integers indicating the belt the face belongs to.
edgeLengththe length of an average edge in km and degrees.
graphan 'igraph' class graph object.
lengthinteger vector of length=3. The number of vertices, edges and faces in this order.
crsa CRS class object, by design this is the authalic sphere (ESRI:37008)
rthe radius of the grid
spThe SpatialPolygons representation of the grid. If missing, it can be created with newsp().
sfThe sf representation of the grid. If missing, it can be created with newsf().
skeletondata tables with sequential indexing for the C functions.
Examples
# single tessellation value
g <- trigrid(c(8))
g
#> A/An trigrid object with 642 vertices, 1920 edges and 1280 faces.
#> The mean grid edge length is 961.08 km or 8.64 degrees.
#> Use plot3d() to see a 3d render.
# series of tessellations
g1 <- trigrid(c(2,3,4))
g1
#> A/An trigrid object with 5762 vertices, 17280 edges and 11520 faces.
#> The mean grid edge length is 320.81 km or 2.89 degrees.
#> Use plot3d() to see a 3d render.
# based on approximate size (4 degrees edge length)
g2 <- trigrid(deg=4)
#> Selecting trigrid with tessellation vector: c(17).
#> Mean edge length: 4.072 degrees.
