add_RefGrid: Add a Reference grid

View source: R/add_RefGrid.R

add_RefGridR Documentation

Add a Reference grid

Description

Add a Latitude/Longitude reference grid to maps.

Usage

add_RefGrid(
  bb,
  ResLat = 1,
  ResLon = 2,
  LabLon = NA,
  LatR = c(-80, -45),
  lwd = 1,
  lcol = "black",
  fontsize = 1,
  fontcol = "black",
  offset = NA
)

Arguments

bb

bounding box of the first plotted object. for example, bb=st_bbox(SmallBathy()) or bb=st_bbox(MyPolys).

ResLat

numeric, latitude resolution in decimal degrees.

ResLon

numeric, longitude resolution in decimal degrees.

LabLon

numeric, longitude at which Latitude labels should appear. if set, the resulting Reference grid will be circumpolar.

LatR

numeric, range of latitudes of circumpolar grid.

lwd

numeric, line thickness of the Reference grid.

lcol

character, line color of the Reference grid.

fontsize

numeric, font size of the Reference grid's labels.

fontcol

character, font color of the Reference grid's labels.

offset

numeric, offset of the Reference grid's labels (distance to plot border).

See Also

load_Bathy, SmallBathy.

Examples

library(terra)

#Example 1: Circumpolar grid with Latitude labels at Longitude 0

plot(SmallBathy(),breaks=Depth_cuts, col=Depth_cols, legend=FALSE,axes=FALSE,box=FALSE)
add_RefGrid(bb=st_bbox(SmallBathy()),ResLat=10,ResLon=20,LabLon = 0)

#Example 2: Local grid around created polygons

MyPolys=create_Polys(PolyData,Densify=TRUE)
BathyC=crop(SmallBathy(),ext(MyPolys))#crop the bathymetry to match the extent of MyPolys
Mypar=par(mai=c(0.5,0.5,0.5,0.5)) #Figure margins as c(bottom, left, top, right)
par(Mypar)
plot(BathyC,breaks=Depth_cuts, col=Depth_cols, legend=FALSE,axes=FALSE,box=FALSE)
add_RefGrid(bb=st_bbox(BathyC),ResLat=2,ResLon=6)
plot(st_geometry(MyPolys),add=TRUE,col='orange',border='brown',lwd=2)


CCAMLRGIS documentation built on Sept. 27, 2023, 9:09 a.m.