Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noWrap for addRasterImage #863

Open
jaseeverett opened this issue May 26, 2023 · 0 comments
Open

noWrap for addRasterImage #863

jaseeverett opened this issue May 26, 2023 · 0 comments

Comments

@jaseeverett
Copy link

For a global raster or SpatRaster, there seems to be no way to switch off wrapping when using leaflet::addRasterImage. It would be great if something similar to options = tileOptions(noWrap = TRUE) could be implemented for rasters as well.

Is there a workaround that I am missing?

library(leaflet)
library(raster)

r <- raster(xmn = -180, xmx = 180, ymn = -30, ymx = 30, nrows = 178, ncols = 360, crs = "EPSG:4326")
values(r) <- matrix(1:(178*360), nrow(r), ncol(r), byrow = FALSE)

pal <- leaflet::colorNumeric("Spectral", values(r),
                             na.color = "transparent")

leaflet::leaflet() %>%
  addTiles(options = leaflet::tileOptions(noWrap = TRUE)) %>%
  leaflet::addRasterImage(r, colors = pal) 
Screenshot 2023-05-26 at 12 23 19 pm

In this example, the map is not wrapped, but the raster layer is wrapped and I can't find a way to stop it happening.
Thanks for a great package. Any advice appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant