Learn R Programming

marmap (version 1.0.10)

scaleBathy: Adds a scale to a map

Description

Uses geographic information from object of class bathy to calculate and plot a scale in kilometer.

Usage

scaleBathy(mat, deg=1, x="bottomleft", y=NULL, inset=10, angle=90, ...)

Value

a scale added to the active graphical device

Arguments

mat

bathymetric data matrix of class bathy, imported using read.bathy

deg

the number of degrees of longitudes to convert into kilometers (default is 1)

x, y

the coordinates used to plot the scale on the map (see Details)

inset

when x is a keyword (e.g. "bottomleft"), inset is a percentage of the plotting space controlling the relative position of the plotted scale (see Examples)

angle

angle from the shaft of the arrow to the edge of the arrow head

...

further arguments to be passed to text

Author

Eric Pante

Details

scaleBathy is a simple utility to add a scale to the lower left corner of a bathy plot. The distance in kilometers between two points separated by 1 degree longitude is calculated based on the minimum latitude of the bathy object used to plot the map. Option deg allows the user to plot the distance separating more than one degree (default is one).

The plotting coordinates x and y either correspond to two points on the map (i.e. longitude and latitude of the point where the scale should be plotted), or correspond to a keyword (set with x, y being set to NULL) from the list "bottomright", "bottomleft", "topright", "topleft". When a keyword is used, the option inset controls how far the scale will be from the edges of the plot.

See Also

plot.bathy

Examples

Run this code
# load NW Atlantic data and convert to class bathy
	data(nw.atlantic)
	atl <- as.bathy(nw.atlantic)

# a simple example
	plot(atl, deep=-8000, shallow=-1000, step=1000, lwd=0.5, col="grey")
	scaleBathy(atl, deg=4)

# using keywords to place the scale with inset=10%
	par(mfrow=c(2,2))
	plot(atl, deep=-8000, shallow=-1000, step=1000, lwd=0.5, col="grey")
	scaleBathy(atl, deg=4, x="bottomleft", y=NULL)
	plot(atl, deep=-8000, shallow=-1000, step=1000, lwd=0.5, col="grey")
	scaleBathy(atl, deg=4, x="bottomright", y=NULL)

# using keywords to place the scale with inset=20%
	plot(atl, deep=-8000, shallow=-1000, step=1000, lwd=0.5, col="grey")
	scaleBathy(atl, deg=4, x="topleft", y=NULL, inset=20)
	plot(atl, deep=-8000, shallow=-1000, step=1000, lwd=0.5, col="grey")
	scaleBathy(atl, deg=4, x="topright", y=NULL, inset=20) 

Run the code above in your browser using DataLab