scaleBar {mapmisc} | R Documentation |
Utilities for plotting a map, adding a scale bar and north arrow, and adding a legend of colour scales.
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 = extent(-180,xmax=180, ymin=-47, ymax=71), outer=TRUE, ...)
crs |
A |
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 |
... |
Additional arguments passed to |
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
.
Patrick Brown
Npoints = 20 myPoints = SpatialPointsDataFrame( cbind(runif(Npoints), 51+runif(Npoints)), data=data.frame(y1=c(NA, rnorm(Npoints-1)), y2=c(sample(0:5, Npoints-1,replace=TRUE), NA)), proj4string=CRS( "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" ) ) ## Not run: mymap = openmap(myPoints) ## End(Not run) breaks = c(-100, -1, 1, Inf) thecol = c('red','orange','blue') map.new(myPoints) ## Not run: plot(mymap,add=TRUE) ## End(Not run) plot(myPoints,col = as.character(cut( myPoints$y1, breaks, thecol )),add=TRUE) scaleBar(myPoints, "bottomright",cex=1.25, seg.len=2) temp=legendBreaks("topleft", legend=breaks, col=thecol) ## Not run: thedot = insetMap(myPoints, "bottomleft",col='#00000000', lty=0) points(thedot) ## End(Not run)