create_scale_bar | R Documentation |
Function from 3wen/legendMap repo for 'adding a North arrow and/or a scale bar to maps done using ggplot2'. All credit for this function goes to Ewen Gallic. All notation and documentation is from Ewen Gallic.
This function creates a scale bar. See https://github.com/3wen/legendMap.git for examples.
create_scale_bar( lon, lat, distance_lon, distance_lat, distance_legend, dist_units = "km" )
lon |
Longitude of the bottom left point of the first rectangle to draw. |
lat |
Latitude of the bottom left point of the first rectangle to draw. |
distance_lon |
Length of each rectangle. |
distance_lat |
Width of each rectangle. |
distance_legend |
Distance between rectangles and legend texts. |
dist_units |
Units of distance "km" (kilometers) (default), "nm" (nautical miles), "mi" (statute miles). |
Return a list whose elements are; 'rectangle': a data.frame containing the coordinates to draw the first rectangle, 'rectangle2': a data.frame containing the coordinates to draw the second rectangle, and 'legend': a data.frame containing the coordinates of the legend texts, and the texts as well.
https://github.com/3wen/legendMap.git
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.