Learn R Programming

quadmesh (version 0.2.0)

mesh_plot: Plot as a mesh

Description

Convert to a quadmesh and plot in efficient vectorized form using 'grid'.

Usage

mesh_plot(x, crs = NULL, colfun = NULL, add = FALSE, ...)

# S3 method for BasicRaster mesh_plot(x, crs = NULL, colfun = NULL, add = FALSE, ...)

# S3 method for RasterLayer mesh_plot(x, crs = NULL, colfun = NULL, add = FALSE, ...)

Arguments

x

object to convert to mesh and plot

crs

target map projection

colfun

colour function to use, `viridis` is the default

add

add to existing plot or start a new one

...

ignored

Value

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

Details

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 'colfun' argument is used to generate colours which are mapped to the input object data as in 'image'.

Examples

Run this code
# NOT RUN {
mesh_plot(worldll)
## crop otherwise out of bounds from PROJ
mesh_plot(raster::crop(worldll, raster::extent(-179, 179, -89, 89)), crs = "+proj=laea")
mesh_plot(worldll, crs = "+proj=moll")
prj <- "+proj=lcc +datum=WGS84 +lon_0=147 +lat_0=-40 +lat_1=-55 +lat_2=-20"
mesh_plot(etopo, crs = prj, add = FALSE, colfun = function(n = 20) grey(seq(0, 1, length = n)))
mesh_plot(worldll, crs = prj, add = TRUE)
# }

Run the code above in your browser using DataLab