lonlat {graticule} | R Documentation |
Add longitude latitude lines to a plot
Description
Use the coordinates of the input raster to generate coordinate rasters, these are then used in a contour plot.
Usage
lonlat(
x,
na.rm = FALSE,
lon = FALSE,
lat = FALSE,
...,
plot = TRUE,
add = TRUE
)
Arguments
x |
input raster |
na.rm |
logical, remove missing values from generated coordinates |
lon |
if TRUE, only longitude plotted |
lat |
if TRUE (and 'lon = FALSE') only latitude plotted |
... |
passed to [graphics::contour()] |
plot |
logical, plot the result |
add |
logical, add to current plot or instantiate one |
Details
Plot is added to an existing plot by default.
Value
RasterBrick of the longitude and latitude values, two layers
(invisibly) the raster (RasterBrick) object with longitude and latitude values of the input as two layers, otherwise this function used for side-effect (drawing on a plot)
Examples
plot(c(-180, 180), c(-90, 90))
lonlat(raster::raster())
p <- raster::projectExtent(raster::raster(), "+proj=igh")
lonlat(p, add = FALSE)
lonlat(p, levels = seq(-180, 180, by =15), add = FALSE)
lonlat(p, levels = seq(-180, 180, by = 5), add = FALSE, lon = TRUE)
lonlat(p, levels = seq(-180, 180, by = 15), add = TRUE, lat = TRUE)
[Package graticule version 0.4.0 Index]