scalebar: Adding Scale to Projected Maps

View source: R/spatial_functions.R

scalebarR Documentation

Adding Scale to Projected Maps

Description

This function adds a scale to a projected map created with sp::plot.

Usage

scalebar(loc, length, unit = "km", division.cex = 0.8, ...)

Arguments

loc

A two value numeric vector. The longitude and latitude where the scale bar is to be.

length

numeric. The length of the divisions in the unit specified.

unit

character. Some options are "m" and "km".

division.cex

numeric. The size of the divisions.

...

Other arguments

Value

A sp::plot object with a scale.

Note

For an unprojected map in R, we can use the map.scale function in maps package. This is applicable to a map created not only by the maps package but also by other cartographic packages. However, in R, there is no scale bar applicable to a projected map. So, use it if your shapefile is projected. It should be noted that using scalebar for a decimal degree or the entire world is not logical because the function cannot convert units and retains them in the unconverted form in the current graphic device. Therefore, if necessary, users must project and coordinate the map appropriately prior to the execution of scalebar.

Author(s)

Omer Kara

References

Taken from Auxiliary Cartographic Functions in R: North Arrow, Scale Bar, and Label with a Leader Arrow, Tanimura, 2007. For more information see here.

Examples

## Not run: 
scalebar(c(-124, 26), length = 10000, unit = "km", division.cex = .8) ## Do not run.

## End(Not run)


omerkara/okara documentation built on Nov. 21, 2023, 7:56 p.m.