r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
868 stars 121 forks source link

`unit` argument in `tm_shape()` does not seem to have any effect on the units displayed in scalebar #933

Closed ar-puuk closed 2 months ago

ar-puuk commented 2 months ago

I want to plot a scalebar in "miles". However, no matter what I do, including reprojecting the sf object, I am getting "km" as the unit of scalebar measurement.

library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(tmap)
#> 
#> Attaching package: 'tmap'
#> The following object is masked from 'package:datasets':
#> 
#>     rivers
tmap_mode("plot")
#> ℹ tmap mode set to "plot".

data(NLD_prov)  

tm_shape(NLD_prov) +
  tm_fill("name") +
  tm_scalebar()


NLD_prov <- st_transform(NLD_prov, "EPSG:2240")

tm_shape(NLD_prov, unit = "mi") +
  tm_fill("name") +
  tm_scalebar()

Created on 2024-09-08 with reprex v2.1.1

mtennekes commented 2 months ago

Thx! Fixed

ar-puuk commented 2 months ago

Thanks a lot, it looks like the issue has been fixed. Much appreciated.