Pakillo/CityShadeMapper

rayshader uses height matrix filled by column, not by rows

Pakillo opened this issue · 0 comments

library(terra)
#> terra 1.5.21
library(raster)
#> Loading required package: sp

r = rast(nrows = 3, ncols = 3, xmin = 0, xmax = 3, ymin = 0, ymax = 3, 
         resolution = 1, vals = 1:9)
plot(r)

raster <- raster(r)

m <- matrix(raster::extract(raster, raster::extent(raster)), 
              nrow = ncol(raster), ncol = nrow(raster))

m
#>      [,1] [,2] [,3]
#> [1,]    1    4    7
#> [2,]    2    5    8
#> [3,]    3    6    9

See https://github.com/tylermorganwall/rayshader/blob/7d19e315c8f171f88bc11eb30f7c464ebc672cdd/R/raster_to_matrix.R#L33

Need to transpose resulting matrix in terra_to_matrix