Plots cell values along a vertical transect
transectPlot(
rast = NULL,
sampleAxis = "lon",
axisValue = NA,
scaleRange = NA,
plotLegend = TRUE,
depthLim = as.numeric(max(names(rast))),
transRange = c(-90, 90),
transTicks = 20,
verbose = FALSE,
...
)
A multilayer SpatRaster
object, with names
corresponding to the z coordinate represented by the layer.
These names must be interpretable by as.numeric
.
Specifies whether a latitudinal ("lat") or longitudinal ("long") transect is desired.
Numeric value specifying transect postion.
A numeric vector of length 2, specifying the range that should be used for the plot color scale.
logical
, controls whether legend is plotted.
A single vector of class numeric
. How deep
should the plot go?
A numeric
vector of lenghth 2. How far
along the transect should be plotted?
numeric
, spacing between breaks on x axis.
logical
. Switching to FALSE
mutes message
alerting user if input rast
values exceed specified scaleRange
.
Additional optional arguments to pass to viridis
.
A ggplot
showing a vertical slice through the SpatRaster
.
Only unprojected SpatRaster
files are supported.
library(terra)
rast1 <- rast(ncol=10, nrow=10)
values(rast1) <- rep(0:3, 50)
#> Warning: [setValues] values is larger than the size of cells
rast2 <- rast(ncol=10, nrow=10)
values(rast2) <- c(rep(0, 50), rep(1,25), rep(2,25))
rast3 <- rast(ncol=10, nrow=10)
values(rast3) <- rep(c(1,3,2,1), 25)
distBrick <- c(rast1, rast2, rast3)
names(distBrick) <- c(0:2)
transectPlot(distBrick, depthLim = 3)
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.