In plot_map, raster is used to plot the rayshader matrix and sets the xmn/xmx, ymn/ymx equal to the first and last centre coordinates that are passed to rgl.surface.
This could offset the min and max values by 0.5 to be aligned to the data as represented by plot_3d, and it comes down to this code in plot_map:
Raster is based on an areal extent, and so setting the extent to the point coordinate is reducing the range by a half-cell on every side. It means that when adding the centre coordinates (1:ncol, 1:nrow) to the plot_map image they will fall properly in the centre.
m <- matrix(c(1:5, 5, 6:1), 3, 4)
l <- list(x = seq(1, nrow(m)), y = seq(1, ncol(m)), z = m)
r <- raster::raster(l)
library(raster)
library(rayshader)
plot_map(ambient_shade(t(as.matrix(r))))
## in master these don't fall correctly in the centre, with the half-cell mod they do
points(coordinates(r))
Please consider applying this change, it makes the two visual outputs (plot_map and plot_3d) easier to compare exactly (though it won't be noticed in normal usage considering how tiny the difference is - it will affect some careful examples that I am working on).
In
plot_map
, raster is used to plot the rayshader matrix and sets the xmn/xmx, ymn/ymx equal to the first and last centre coordinates that are passed torgl.surface
.This could offset the min and max values by 0.5 to be aligned to the data as represented by
plot_3d
, and it comes down to this code in plot_map:Raster is based on an areal extent, and so setting the extent to the point coordinate is reducing the range by a half-cell on every side. It means that when adding the centre coordinates (1:ncol, 1:nrow) to the plot_map image they will fall properly in the centre.
Please consider applying this change, it makes the two visual outputs (plot_map and plot_3d) easier to compare exactly (though it won't be noticed in normal usage considering how tiny the difference is - it will affect some careful examples that I am working on).
Thanks!