mf_scale | R Documentation |
Plot a scale bar.
mf_scale(
size,
pos = "bottomright",
lwd = 1.5,
cex = 0.6,
col,
crs_units = "m",
scale_units = "km",
x,
unit
)
size |
size of the scale bar in scale units ( |
pos |
position. It can be one of 'bottomright', 'bottomleft', 'interactive' or a vector of two coordinates in map units (c(x, y)). |
lwd |
line width of the scale bar |
cex |
size of the scale bar text |
col |
color of the scale bar (line and text) |
crs_units |
units used in the CRS of the currently plotted layer. Possible values are "m" and "ft" (see Details). |
scale_units |
units used for the scale bar. Can be "mi" for miles, "ft" for feet, "m" for meters, or "km" for kilometers (default). |
x |
object of class crs, sf or sfc. If set, the CRS of x will be used
instead of |
unit |
deprecated, use scale_units instead |
Most CRS use the meter as unit. Some US CRS use feet or US survey
feet. If unsure of the unit used in the CRS you can use the x argument of the
function.
Alternatively, you can use
sf::st_crs(zz, parameters = TRUE)$units_gdal
to see which units
are used in the zz
layer.
This scale bar does not work on unprojected (long/lat) maps.
No return value, a scale bar is displayed.
mtq <- mf_get_mtq()
mf_map(mtq)
mf_scale()
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf"))[1, ]
nc_foot <- st_transform(nc, 2264) # NC state plane, US foot
mf_map(nc_foot)
mf_scale(size = 5, crs_units = "ft", scale_units = "mi")
mf_map(nc_foot)
mf_scale(size = 5, x = nc_foot, scale_units = "mi")
nc_meter <- st_transform(nc, 32119) # NC state plane, m
mf_map(nc_meter)
mf_scale(size = 5, crs_units = "m", scale_units = "mi")
mf_scale(size = 5, crs_units = "m", scale_units = "km", pos = "bottomleft")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.