-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Thank you for developing tmap! It is really becoming a great package, allowing my group to replace desktop GIS systems for map production. Great job!
We are building marine species distribution models that must use equal area coordinate systems such as Albers Equal Area. Often these use conic projections, and we want the map to be rendered in these coordinate systems so that rasters of predicted species densities have perfectly square grid cells.
But when we add a basemap, not all of the plot area is filled by it. The amount unfilled depends on the coordinate system parameters and the area of the earth being plotted. For example, in the attached image of eastern North America, you can see a white patch at the top.
My guess is that the code that's retrieving and projecting basemap tiles is computing an extent based on the data being plotted rather than the extent of whats actually visible in the rendered plot. Is there any way to fix this? I can guess that computing exactly what is needed will be tricky. If that's not possible, can you introduce some parameter to tm_basemap() that allows the user to specify a buffer to work around this, or a similar kludge? Thanks for your consideration.
Here's some repro code. I attached the shapefile.
library(sf)
library(tmap)
aea_poly <- st_read("AEA_polygon.shp")
tm <- tm_shape(aea_poly, is.main = TRUE) +
tm_polygons(fill_alpha = 0) +
tm_basemap("Esri.OceanBasemap") +
tm_crs(st_crs(aea_poly)) # Necessary to have map render in Albers, even with is.main = TRUE above
tmap_save(tm, "AEA_polygon_map.png")
Session info:
> devtools::session_info()
- Session info --------------------------------------------------------------------------------------------------------------------------------------------
setting value
version R version 4.4.3 (2025-02-28 ucrt)
os Windows Server 2019 x64 (build 17763)
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz America/New_York
date 2025-06-11
rstudio 2025.05.0+496 Mariposa Orchid (desktop)
pandoc NA
quarto ERROR: Unknown command "TMPDIR=C:/Users/jjr8/AppData/Local/Temp/2/RtmpiOdYAz/file36f42b8684". Did you mean command "install"? @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\quarto.exe
- Packages ------------------------------------------------------------------------------------------------------------------------------------------------
package * version date (UTC) lib source
abind 1.4-8 2024-09-12 [1] CRAN (R 4.4.1)
base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.4.0)
cachem 1.1.0 2024-05-16 [1] CRAN (R 4.4.3)
class 7.3-23 2025-01-01 [2] CRAN (R 4.4.3)
classInt 0.4-11 2025-01-08 [1] CRAN (R 4.4.3)
cli 3.6.4 2025-02-13 [1] CRAN (R 4.4.3)
codetools 0.2-20 2024-03-31 [2] CRAN (R 4.4.3)
colorspace 2.1-1 2024-07-26 [1] CRAN (R 4.4.2)
cols4all 0.8 2024-10-16 [1] CRAN (R 4.4.3)
crosstalk 1.2.1 2023-11-23 [1] CRAN (R 4.4.3)
curl 6.2.1 2025-02-19 [1] CRAN (R 4.4.3)
data.table 1.17.0 2025-02-22 [1] CRAN (R 4.4.3)
DBI 1.2.3 2024-06-02 [1] CRAN (R 4.4.3)
devtools 2.4.5 2022-10-11 [1] CRAN (R 4.4.3)
dichromat 2.0-0.1 2022-05-02 [1] CRAN (R 4.4.0)
digest 0.6.37 2024-08-19 [1] CRAN (R 4.4.3)
e1071 1.7-16 2024-09-16 [1] CRAN (R 4.4.3)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.4.2)
fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.2)
fs 1.6.5 2024-10-30 [1] CRAN (R 4.4.3)
glue 1.8.0 2024-09-30 [1] CRAN (R 4.4.2)
htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.3)
htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.4.3)
httpuv 1.6.15 2024-03-26 [1] CRAN (R 4.4.2)
KernSmooth 2.23-26 2025-01-01 [2] CRAN (R 4.4.3)
later 1.4.1 2024-11-27 [1] CRAN (R 4.4.2)
lattice 0.22-6 2024-03-20 [2] CRAN (R 4.4.3)
leafem 0.2.4 2025-05-01 [1] CRAN (R 4.4.3)
leaflegend 1.2.1 2024-05-09 [1] CRAN (R 4.4.3)
leaflet 2.2.2 2024-03-26 [1] CRAN (R 4.4.3)
leaflet.providers 2.0.0 2023-10-17 [1] CRAN (R 4.4.3)
leafsync 0.1.0 2019-03-05 [1] CRAN (R 4.4.3)
lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.2)
logger 0.4.0 2024-10-22 [1] CRAN (R 4.4.3)
lwgeom 0.2-14 2024-02-21 [1] CRAN (R 4.4.3)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.4.2)
maptiles 0.10.0 2025-05-07 [1] CRAN (R 4.4.3)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.4.3)
mime 0.13 2025-03-17 [1] CRAN (R 4.4.3)
miniUI 0.1.2 2025-04-17 [1] CRAN (R 4.4.3)
pkgbuild 1.4.8 2025-05-26 [1] CRAN (R 4.4.3)
pkgload 1.4.0 2024-06-28 [1] CRAN (R 4.4.3)
png 0.1-8 2022-11-29 [1] CRAN (R 4.4.0)
profvis 0.4.0 2024-09-20 [1] CRAN (R 4.4.3)
promises 1.3.2 2024-11-28 [1] CRAN (R 4.4.2)
proxy 0.4-27 2022-06-09 [1] CRAN (R 4.4.3)
purrr 1.0.4 2025-02-05 [1] CRAN (R 4.4.2)
R6 2.6.1 2025-02-15 [1] CRAN (R 4.4.3)
raster 3.6-32 2025-03-28 [1] CRAN (R 4.4.3)
RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.4.0)
Rcpp 1.0.14 2025-01-12 [1] CRAN (R 4.4.2)
remotes 2.5.0 2024-03-17 [1] CRAN (R 4.4.3)
rlang 1.1.5 2025-01-17 [1] CRAN (R 4.4.2)
rstudioapi 0.17.1 2024-10-22 [1] CRAN (R 4.4.3)
s2 1.1.9 2025-05-23 [1] CRAN (R 4.4.3)
sessioninfo 1.2.3 2025-02-05 [1] CRAN (R 4.4.3)
sf * 1.0-21 2025-05-15 [1] CRAN (R 4.4.3)
shiny 1.10.0 2024-12-14 [1] CRAN (R 4.4.3)
slippymath 0.3.1 2019-06-28 [1] CRAN (R 4.4.3)
sp 2.2-0 2025-02-01 [1] CRAN (R 4.4.3)
spacesXYZ 1.6-0 2025-06-06 [1] CRAN (R 4.4.3)
stars 0.6-8 2025-02-01 [1] CRAN (R 4.4.3)
terra 1.8-54 2025-06-01 [1] CRAN (R 4.4.3)
tmap * 4.1 2025-05-12 [1] CRAN (R 4.4.3)
tmaptools 3.2 2025-01-13 [1] CRAN (R 4.4.3)
units 0.8-7 2025-03-11 [1] CRAN (R 4.4.3)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.4.3)
usethis 3.1.0 2024-11-26 [1] CRAN (R 4.4.3)
vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.4.2)
viridisLite 0.4.2 2023-05-02 [1] CRAN (R 4.4.2)
wk 0.9.4 2024-10-11 [1] CRAN (R 4.4.3)
XML 3.99-0.18 2025-01-01 [1] CRAN (R 4.4.3)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.4.3)
[1] C:/Users/jjr8/AppData/Local/R/win-library/4.4
[2] C:/Program Files/R/R-4.4.3/library
* -- Packages attached to the search path.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Warning message:
In system2("quarto", "-V", stdout = TRUE, env = paste0("TMPDIR=", :
running command '"quarto" TMPDIR=C:/Users/jjr8/AppData/Local/Temp/2/RtmpiOdYAz/file36f42b8684 -V' had status 1