I am using leaflet to visualize rasters. The output shows NA values around the border areas for discrete classifications. I read another post that said this might be due to the differences in projections between the raster and what leaflet uses, resulting in NA interpolated values at the edges. I tried leaflet:projectForLeafLet, but this did not change the problem.
r r1 <- asFactor(r) r2 <- projectRasterForLeafLet(r1, method = 'ngb') pal <- colorFactor(SAGA_pal[], domain = c(0,10,15,20,30), ordered = FALSE, na.color = "transparent", alpha = FALSE, reverse = TRUE) (ll <- leaflet() %>% addProviderTiles("Esri.WorldImagery") %>% addRasterImage(r2, colors=pal, opacity=0.5) %>% addLegend(pal=pal, values=values(r2)) )