addscalebar: Auto Plot Scalebar

View source: R/scalebar.R

addscalebarR Documentation

Auto Plot Scalebar

Description

Automatically determines the geographical scale of the plot and draws a labelled scalebar.

Usage

addscalebar(
  plotunit = NULL,
  plotepsg = NULL,
  widthhint = 0.25,
  unitcategory = "metric",
  htin = 0.1,
  padin = c(0.15, 0.15),
  style = "bar",
  bar.cols = c("black", "white"),
  lwd = 1,
  linecol = "black",
  tick.cex = 0.7,
  labelpadin = 0.08,
  label.cex = 0.8,
  label.col = "black",
  pos = "bottomleft"
)

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"

htin

Height (in inches) of the desired scale bar

padin

A vector of length 2 determining the distance in inches between the scalebar and the edge of the plottable area.

style

One of "bar" or "ticks".

bar.cols

If style=="bar", the colors to be repeated to make the bar.

lwd

The line width to use when drawing the scalebar

linecol

The line color to use when drawing the scalebar

tick.cex

If style=="ticks", the height of interior ticks.

labelpadin

The distance between the end of the scalebar and the label (inches)

label.cex

The font size of the label

label.col

The color of the label

pos

Where to align the scalebar. One of "bottomleft", "bottomright", "topleft", or "topright".

Examples

plot(1:5, 1:5, asp=1)
addscalebar(plotunit="m")


prettymapr documentation built on May 29, 2024, 5:38 a.m.