Automatically determines the geographical scale of the plot and draws a labelled scalebar.
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"
)
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.
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.
The fraction of the plottable width which the scale bar should (mostly) occupy.
One of "metric" or "imperial"
Height (in inches) of the desired scale bar
A vector of length 2 determining the distance in inches between the scalebar and the edge of the plottable area.
One of "bar" or "ticks".
If style=="bar"
, the colors to be repeated to make the bar.
The line width to use when drawing the scalebar
The line color to use when drawing the scalebar
If style=="ticks"
, the height of interior ticks.
The distance between the end of the scalebar and the label (inches)
The font size of the label
The color of the label
Where to align the scalebar. One of "bottomleft", "bottomright", "topleft", or "topright".
plot(1:5, 1:5, asp=1)
addscalebar(plotunit="m")
Run the code above in your browser using DataLab