Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addCompass

Add Compass Rose to Map


Description

Add a compass rose to an existing map, similar to those found on nautical charts showing both true north and magnetic north.

Usage

addCompass(X, Y, rot="magN", useWest=TRUE, year,
   cex=1, col.compass=c("gainsboro","blue","yellow","black"), ...)

Arguments

X

numeric – longitude coordinate (degrees N) for centroid of compass rose.

Y

numeric – latitude coordinate (degrees W) for centroid of compass rose.

rot

numeric|character – Rotation (degrees) counterclockwise from 0 degrees (true North, see details).

useWest

logical – if TRUE, assumes longitude coordinates are centered on Greenwich extending westward to -180 and eastward to 180.

year

numeric – specific year to use from IGRF-13 (see details).

cex

numeric – character expansion to use in the display.

col.compass

character – colours for compass rose components (in order):
1=background compass, 2=rotated arms, 3=central button, 4=pch (border).

...

dots – additional parameters to pass to the text function.

Details

The basic idea comes from Jim Lemon (see References), but is modified here to reflect a compass rose used on BC nautical charts.

The default rotation ("magN") is a calculation of the initial bearing of a great-circle arc from the compass position to the north geomagnetic rot using the function calcGCdist. The default year is the current year, but the user can choose years from 1900 to 2025 for approximate rot locations using model output from NOAA's IGRF-13 (International Geomagnetic Reference Field).

The user can also specify a fixed rotation (e.g. rot=-30) or no rotation (either rot=0 or rot="trueN").

Value

No value returned.

Author(s)

Rowan Haigh, Program Head – Offshore Rockfish
Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC
locus opus: Institute of Ocean Sciences (IOS), Sidney BC
Last modified Rd: 2021-01-04

References

See Also

Examples

local(envir=.PBSmapEnv,expr={
  data(nepacLL,envir=.PBSmapEnv)
  par(mfrow=c(1,1),mar=c(3,4,0.5,0.5))
  plotMap(nepacLL, xlim=c(-134.5,-124.5), ylim=c(48,55), plt=NULL,
    col="lightyellow", cex.axis=1.2, cex.lab=1.5)
  addCompass(-132, 49.5, rot=-12, cex=1.5)
})

PBSmapping

Mapping Fisheries Data and Spatial Analysis Tools

v2.73.0
GPL (>= 2)
Authors
Jon T. Schnute [aut], Nicholas Boers [aut], Rowan Haigh [aut, cre], Alex Couture-Beil [ctb], Denis Chabot [ctb], Chris Grandin [ctb], Angus Johnson [ctb], Paul Wessel [ctb], Franklin Antonio [ctb], Nicholas J. Lewin-Koh [ctb], Roger Bivand [ctb]
Initial release
2021-01-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.