When creating a map with ggplot() and geom_sf() and using scalebar(), if your sf data object has a column named label, the information in that column is used instead of the proper unit labels specified in scalebar(). For example:
You can work around this by changing the name of the column in the sf object to anything else, e.g.
st <- st %>% rename(.label = label)
ggplot(data=st) +
geom_sf() +
scalebar(data=st, dist_unit="km", dist=100, transform=T)
Naming the label column scalebar() creates to something other than label and less likely to overlap with sf column names should solve this. I can write a PR if you want.
Using
ggsn 0.5.0
:When creating a map with
ggplot()
andgeom_sf()
and usingscalebar()
, if yoursf
data object has a column namedlabel
, the information in that column is used instead of the proper unit labels specified inscalebar()
. For example:You can work around this by changing the name of the column in the
sf
object to anything else, e.g.Naming the label column
scalebar()
creates to something other thanlabel
and less likely to overlap withsf
column names should solve this. I can write a PR if you want.https://github.com/oswaldosantos/ggsn/blob/1e2088450f227653d454d92801de0f80e17dbccd/R/scalebar.R#L236