scaleBar {mapmisc} | R Documentation |
Scale bar and inset map
Description
Utilities for plotting a map, adding a scale bar and north arrow, and adding a legend of colour scales.
Usage
scaleBar(crs, pos = "bottomright",
cex=1,
pt.cex = 1.1*cex,
seg.len=5*cex,
title.cex=cex,
outer=TRUE,...)
insetMap(crs, pos="bottomright",map="osm",zoom=0,
width=max(c(0.2, 1-par('plt')[2])),
col="#FF000090", borderMap=NULL,
cropInset = terra::ext(-180, 180, -47, 71),
outer=TRUE, inset = c(0.1, 0.1), ...)
Arguments
crs |
A character string from which a projection
can be extracted with |
pos |
Position, as specified in the |
cex |
scaling factor for the legend |
pt.cex |
Scaling factor north arrow (can be zero). |
seg.len |
approximate length (in character units) of the scale bar. can be zero. |
title.cex |
scaling for the distance text |
outer |
If |
map |
Either a Raster for the inset map or a string
passed to |
zoom |
Zoom level if retrieving inset map from |
width |
Width of the inset map, as a fraction of the plot window |
col |
Colour for shaded region of inset map |
borderMap |
border style for the inset map (passed to |
cropInset |
Crop the insert map to this extent |
inset |
how far from the border to put the inset map |
... |
Additional arguments passed to |
Details
scaleBar
produces a scale bar reflecting the distance travelling on a great circle
from the centre of the plot and travelling to the right. The length of the bar is the width
of 6 characters times scale.cex
.
Value
A list containig coordinates of the elements of the scale bar.
Author(s)
Patrick Brown
Examples
Npoints = 20
set.seed(0)
myPoints = vect(
cbind(runif(Npoints)-0.1, 51+runif(Npoints)),
atts=data.frame(
y1=c(NA, rnorm(Npoints-1)),
y2=c(sample(0:5, Npoints-1,replace=TRUE), NA)
),
crs=crsLL)
breaks = c(-100, -1, 1, Inf)
thecol = c('red','orange','blue')
oldpar = map.new(myPoints)
plot(myPoints,col = as.character(cut(
myPoints$y1, breaks, thecol
)),add=TRUE)
scaleBar(myPoints, "bottomright",cex=1.25, seg.len=2)
legendBreaks("topleft", legend=breaks, col=thecol)
thedot = insetMap(crs=myPoints,
pos="bottomleft",
col='#00000000', lty=0, outer=FALSE, width=0.25)
points(thedot)
par(oldpar)