scalebarparams: Get Scale Bar Parameters

Description Usage Arguments Value See Also Examples

Description

Get default scale bar parameters based on the current plot (i.e. par("usr")). The algorithm attempts to detect the best equally divisable distance to use for the scale bar, and returns a list object with attributes that allow any type of scale bar to be drawn. The only way to manipulate the values chosen by the algorithm is to change the widthhint argument. For generic XY plots, pass plotunit.

Usage

1
2
scalebarparams(plotunit = NULL, plotepsg = NULL, widthhint = 0.25,
  unitcategory = "metric", extents = graphics::par("usr"))

Arguments

plotunit

The unit which the current plot is plotted in, one of cm, m, km, in, ft, mi. or latlon. This parameter is optional if plotepsg is passed.

plotepsg

The projection of the current plot. If extents are valid lat/lons, the projection is assumed to be lat/lon (EPSG:4326), or Spherical Mercator otherwise (EPSG:3857). This is done to work seamlessly with OpenStreetMap packages.

widthhint

The fraction of the plottable width which the scale bar should (mostly) occupy.

unitcategory

One of "metric" or "imperial"

extents

The plot extents

Value

a list of parameters: $widthu (width of the scalebar in human readable units); $unit (the human readable unit); $majordivu (the size of the divisions in human readable units); $majordivs (the number of divisions); $widthplotunit (width of the scalebar in plotting units); $majordivplotunit (the width of divisions in plotting units); $labeltext (label text); and extents the user extents (par('usr')) that were used to calculate the parameters.

See Also

addscalebar

Examples

1
2
3
4
5
6
7
plot(1:5, 1:5, asp=1)
scalebarparams(plotunit="m")

library(maptools)
data(wrld_simpl)
plot(wrld_simpl, xlim=c(-66.86, -59.75), ylim=c(43, 47.3)) # Nova Scotia
scalebarparams()

prettymapr documentation built on May 2, 2019, 9:13 a.m.