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)
Run the code above in your browser using DataLab