mesh_plot: Plot a mesh surface in 2D

View source: R/mesh_plot.R

mesh_plotR Documentation

Plot a mesh surface in 2D

Description

Draw a 2D interpretation of a mesh object, or a mesh-alike object. This is very fast and can be used to created approximately continuously varying surface plots.

Usage

mesh_plot(
  x,
  col = NULL,
  add = FALSE,
  zlim = NULL,
  ...,
  coords = NULL,
  crs = NULL
)

## S3 method for class 'mesh3d'
mesh_plot(
  x,
  col = NULL,
  add = FALSE,
  zlim = NULL,
  ...,
  coords = NULL,
  crs = NULL
)

## S3 method for class 'BasicRaster'
mesh_plot(
  x,
  col = NULL,
  add = FALSE,
  zlim = NULL,
  ...,
  coords = NULL,
  crs = NULL
)

## S3 method for class 'sc'
mesh_plot(
  x,
  col = NULL,
  add = FALSE,
  zlim = NULL,
  ...,
  coords = NULL,
  crs = NULL
)

## Default S3 method:
mesh_plot(
  x,
  col = NULL,
  add = FALSE,
  zlim = NULL,
  ...,
  coords = NULL,
  crs = NULL
)

## S3 method for class 'triangulation'
mesh_plot(
  x,
  col = NULL,
  add = FALSE,
  zlim = NULL,
  ...,
  coords = NULL,
  crs = NULL
)

Arguments

x

object to convert to mesh and plot

col

colours to use, defaults to that used by graphics::image()

add

add to existing plot or start a new one

zlim

unimplemented (was used in 'quadmesh::mesh_plot')

...

passed through to base::plot

coords

optional input raster of coordinates of each cell, see details

crs

target map projection

Details

The input is treated as a mesh and plotted in vectorized form using 'grid'.

The mesh may be reprojected prior to plotting using the 'crs' argument to define the target map projection in 'PROJ string' format. (There is no "reproject" function for quadmesh, this is performed directly on the x-y coordinates of the 'quadmesh' output). The 'col' argument are mapped to the inputdata as in graphics::image().

The coords argument only applies to a raster object. The crs argument only applies to a spatial object that has a crs projection metadata string understood by anglr (works, but still work in progress). There is a change from the previous quadmesh::mesh_plot() function that requires both crs and coords to be named. In quadmesh, crs was the second argument to the mesh_plot() function and so in usage was normally not named.

If coords is supplied, it is currently assumed to be a 2-layer RasterBrick with longitude and latitude as the cell values. These are used to geographically locate the resulting mesh, and will be transformed to the crs if that is supplied. This is modelled on the approach to curvilinear grid data used in the angstroms package. There the function angstroms::romsmap() and 'angstroms::romscoords()“ are used to separate the complicated grid geometry from the grid data itself.

If the input is a mesh3d and has a material texture image this is approximated by averaging the RGB values of each primitive's corner into a constant colour for that face. If you would like to avoid this texture colour, set the 'mesh3d$material$color' property to NULL.

Value

nothing, used for the side-effect of creating or adding to a plot


r-gris/trimesh documentation built on Nov. 18, 2022, 2:46 a.m.