r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
856 stars 119 forks source link

Cannot plot raster stack #537

Closed ailich closed 3 years ago

ailich commented 3 years ago

I'm running into issues when trying to plot raster stacks. I believe this is how I've done it in the past. It also may be a stars package issue as I believe tmap converts raster to stars objects before plotting. Currently running the latest development versions of raster, stars, and tmap (raster 3.4-8, stars 0.4-4, tmap 3.2) with R 3.6.3.

library(raster)
library(tmap)
library(stars)

r<- raster(volcano)
r_stack<- stack(r, focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=mean, na.rm=TRUE), focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=sd, na.rm=TRUE))

names(r_stack)
#"layer.1" "layer.2" "layer.3"
nlayers(r_stack)
#3

tm_shape(r_stack)+
  tm_raster()+
  tm_facets()
# Error in dim.stars(x) : length(d) == length(dim(x[[1]])) is not TRUE
# In addition: Warning message:
#   Currect projection of shape stars_obj unknown. Long lat (epsg 4326) coordinates assumed

stars_obj<- st_as_stars(r_stack)
tm_shape(stars_obj)+
  tm_raster()+
 tm_facets()
#Error in dim.stars(x) : length(d) == length(dim(x[[1]])) is not TRUE
#In addition: Warning message:
#Currect projection of shape stars_obj unknown. Long lat (epsg 4326) coordinates assumed. 

stars_obj
# stars object with 3 dimensions and 1 attribute
# attribute(s):
#   layer.1       
# Min.   :  0.000  
# 1st Qu.:  3.586  
# Median :109.222  
# Mean   : 88.898  
# 3rd Qu.:138.333  
# Max.   :195.000  
# NA's   :584      
# dimension(s):
#      from to offset      delta refsys point                    values x/y
# x       1 61      0  0.0163934     NA    NA                      NULL [x]
# y       1 87      1 -0.0114943     NA    NA                      NULL [y]
# band    1  3     NA         NA     NA    NA layer.1, layer.2, layer.3   

View(stars_obj)

stars_obj

mtennekes commented 3 years ago

It works with R 4.0.3, stars 0.4-4, and raster 3.4-5. So it's difficult for me to trace back.

Does plot(stars_obj) work?

Nowosad commented 3 years ago

@mtennekes I can reproduce this error (see also my system info attached). I plan to change versions of some packages and will let you know if it makes things work.

library(raster)
#> Loading required package: sp
library(tmap)
library(stars)
#> Loading required package: abind
#> Loading required package: sf
#> Linking to GEOS 3.8.1, GDAL 3.1.4, PROJ 6.3.2

r<- raster(volcano)
r_stack<- stack(r, focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=mean, na.rm=TRUE), focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=sd, na.rm=TRUE))

names(r_stack)
#> [1] "layer.1" "layer.2" "layer.3"
nlayers(r_stack)
#> [1] 3

tm_shape(r_stack)+
  tm_raster()+
  tm_facets()
#> Warning: Currect projection of shape r_stack unknown. Long lat (epsg 4326)
#> coordinates assumed.
#> Error in dim.stars(x): length(d) == length(dim(x[[1]])) is not TRUE
stars_obj<- st_as_stars(r_stack)
tm_shape(stars_obj)+
  tm_raster()+
  tm_facets()
#> Warning: Currect projection of shape stars_obj unknown. Long lat (epsg 4326)
#> coordinates assumed.
#> Error in dim.stars(x): length(d) == length(dim(x[[1]])) is not TRUE

Created on 2021-01-05 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.3 (2020-10-10) #> os Fedora 33 (Thirty Three) #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Warsaw #> date 2021-01-05 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> abind * 1.4-5 2016-07-21 [1] CRAN (R 4.0.3) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3) #> base64enc 0.1-3 2015-07-28 [2] CRAN (R 4.0.2) #> callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.3) #> class 7.3-17 2020-04-26 [2] CRAN (R 4.0.3) #> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.3) #> cli 2.2.0 2020-11-20 [1] CRAN (R 4.0.3) #> codetools 0.2-16 2018-12-24 [2] CRAN (R 4.0.3) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.3) #> crosstalk 1.1.0.1 2020-03-13 [1] CRAN (R 4.0.3) #> curl 4.3 2019-12-02 [1] CRAN (R 4.0.3) #> DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.3) #> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.3) #> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.3) #> dichromat 2.0-0 2013-01-24 [1] CRAN (R 4.0.3) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3) #> dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.3) #> e1071 1.7-4 2020-10-14 [1] CRAN (R 4.0.3) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.3) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.3) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.3) #> generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.3) #> glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.2) #> highr 0.8 2019-03-20 [3] CRAN (R 4.0.2) #> htmltools 0.5.0 2020-06-16 [2] CRAN (R 4.0.2) #> htmlwidgets 1.5.3 2020-12-10 [1] CRAN (R 4.0.3) #> httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.3) #> KernSmooth 2.23-17 2020-04-26 [2] CRAN (R 4.0.3) #> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.3) #> lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.3) #> leafem 0.1.3 2020-07-26 [1] CRAN (R 4.0.3) #> leaflet 2.0.3 2019-11-16 [1] CRAN (R 4.0.3) #> leafsync 0.1.0 2019-03-05 [1] CRAN (R 4.0.3) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.3) #> lwgeom 0.2-5 2020-06-12 [1] CRAN (R 4.0.3) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.3) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.3) #> mime 0.9 2020-02-04 [2] CRAN (R 4.0.2) #> pillar 1.4.7 2020-11-20 [1] CRAN (R 4.0.3) #> pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.0.3) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3) #> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.3) #> png 0.1-7 2013-12-03 [1] CRAN (R 4.0.3) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3) #> processx 3.4.5 2020-11-30 [1] CRAN (R 4.0.3) #> ps 1.5.0 2020-12-05 [1] CRAN (R 4.0.3) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.3) #> R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.3) #> raster * 3.4-8 2020-12-30 [1] Github (rspatial/raster@5d45681) #> RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.3) #> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.3) #> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.3) #> rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.3) #> rmarkdown 2.6 2020-12-14 [1] CRAN (R 4.0.3) #> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.3) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.3) #> sf * 0.9-7 2020-12-30 [1] Github (r-spatial/sf@79bfbb4) #> sp * 1.4-4 2020-10-07 [1] CRAN (R 4.0.3) #> stars * 0.4-4 2020-12-30 [1] Github (r-spatial/stars@600f02d) #> stringi 1.5.3 2020-09-09 [2] CRAN (R 4.0.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.3) #> testthat 3.0.1 2020-12-17 [1] CRAN (R 4.0.3) #> tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.3) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.3) #> tmap * 3.2 2020-12-30 [1] Github (mtennekes/tmap@51f7af6) #> tmaptools 3.1 2020-12-30 [1] Github (mtennekes/tmaptools@ddcec60) #> units 0.6-7 2020-06-13 [1] CRAN (R 4.0.3) #> usethis 2.0.0 2020-12-10 [1] CRAN (R 4.0.3) #> vctrs 0.3.6 2020-12-17 [1] CRAN (R 4.0.3) #> viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.3) #> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.3) #> xfun 0.19 2020-10-30 [2] CRAN (R 4.0.3) #> XML 3.99-0.5 2020-07-23 [1] CRAN (R 4.0.3) #> xml2 1.3.2 2020-04-23 [1] CRAN (R 4.0.3) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.2) #> #> [1] /home/jn/R/x86_64-redhat-linux-gnu-library/4.0 #> [2] /usr/lib64/R/library #> [3] /usr/share/R/library ```
Nowosad commented 3 years ago

Downgrading raster to the CRAN version did not help. Then, I updated all of my packages, and tried to plot a new stars object - it works:

library(raster)
#> Loading required package: sp
library(tmap)
library(stars)
#> Loading required package: abind
#> Loading required package: sf
#> Linking to GEOS 3.8.1, GDAL 3.1.4, PROJ 6.3.2

r<- raster(volcano)
r_stack<- stack(r, focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=mean, na.rm=TRUE), focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=sd, na.rm=TRUE))

names(r_stack)
#> [1] "layer.1" "layer.2" "layer.3"
nlayers(r_stack)
#> [1] 3

r_stack_stars = st_as_stars(r_stack)
plot(r_stack_stars)

tm_shape(r_stack)+
  tm_raster()+
  tm_facets()
#> Warning: Currect projection of shape r_stack unknown. Long lat (epsg 4326)
#> coordinates assumed.
#> Error in dim.stars(x): length(d) == length(dim(x[[1]])) is not TRUE
stars_obj<- st_as_stars(r_stack)
tm_shape(stars_obj)+
  tm_raster()+
  tm_facets()
#> Warning: Currect projection of shape stars_obj unknown. Long lat (epsg 4326)
#> coordinates assumed.
#> Error in dim.stars(x): length(d) == length(dim(x[[1]])) is not TRUE

Created on 2021-01-05 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.3 (2020-10-10) #> os Fedora 33 (Thirty Three) #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Warsaw #> date 2021-01-05 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> abind * 1.4-5 2016-07-21 [1] CRAN (R 4.0.3) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3) #> base64enc 0.1-3 2015-07-28 [2] CRAN (R 4.0.2) #> callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.3) #> class 7.3-17 2020-04-26 [2] CRAN (R 4.0.3) #> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.3) #> cli 2.2.0 2020-11-20 [1] CRAN (R 4.0.3) #> codetools 0.2-16 2018-12-24 [2] CRAN (R 4.0.3) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.3) #> crosstalk 1.1.0.1 2020-03-13 [1] CRAN (R 4.0.3) #> curl 4.3 2019-12-02 [1] CRAN (R 4.0.3) #> DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.3) #> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.3) #> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.3) #> dichromat 2.0-0 2013-01-24 [1] CRAN (R 4.0.3) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3) #> dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.3) #> e1071 1.7-4 2020-10-14 [1] CRAN (R 4.0.3) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.3) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.3) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.3) #> generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.3) #> glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.2) #> highr 0.8 2019-03-20 [3] CRAN (R 4.0.2) #> htmltools 0.5.0 2020-06-16 [2] CRAN (R 4.0.2) #> htmlwidgets 1.5.3 2020-12-10 [1] CRAN (R 4.0.3) #> httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.3) #> KernSmooth 2.23-17 2020-04-26 [2] CRAN (R 4.0.3) #> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.3) #> lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.3) #> leafem 0.1.3 2020-07-26 [1] CRAN (R 4.0.3) #> leaflet 2.0.3 2019-11-16 [1] CRAN (R 4.0.3) #> leafsync 0.1.0 2019-03-05 [1] CRAN (R 4.0.3) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.3) #> lwgeom 0.2-5 2020-06-12 [1] CRAN (R 4.0.3) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.3) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.3) #> mime 0.9 2020-02-04 [2] CRAN (R 4.0.2) #> pillar 1.4.7 2020-11-20 [1] CRAN (R 4.0.3) #> pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.0.3) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3) #> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.3) #> png 0.1-7 2013-12-03 [1] CRAN (R 4.0.3) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3) #> processx 3.4.5 2020-11-30 [1] CRAN (R 4.0.3) #> ps 1.5.0 2020-12-05 [1] CRAN (R 4.0.3) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.3) #> R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.3) #> raster * 3.4-5 2020-11-14 [1] CRAN (R 4.0.3) #> RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.3) #> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.3) #> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.3) #> rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.3) #> rmarkdown 2.6 2020-12-14 [1] CRAN (R 4.0.3) #> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.3) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.3) #> sf * 0.9-7 2021-01-05 [1] Github (r-spatial/sf@eee9a1e) #> sp * 1.4-4 2020-10-07 [1] CRAN (R 4.0.3) #> stars * 0.4-4 2021-01-05 [1] Github (r-spatial/stars@a78c17d) #> stringi 1.5.3 2020-09-09 [2] CRAN (R 4.0.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.3) #> testthat 3.0.1 2020-12-17 [1] CRAN (R 4.0.3) #> tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.3) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.3) #> tmap * 3.2 2020-12-30 [1] Github (mtennekes/tmap@51f7af6) #> tmaptools 3.1 2020-12-30 [1] Github (mtennekes/tmaptools@ddcec60) #> units 0.6-7 2020-06-13 [1] CRAN (R 4.0.3) #> usethis 2.0.0 2020-12-10 [1] CRAN (R 4.0.3) #> vctrs 0.3.6 2020-12-17 [1] CRAN (R 4.0.3) #> viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.3) #> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.3) #> xfun 0.19 2020-10-30 [2] CRAN (R 4.0.3) #> XML 3.99-0.5 2020-07-23 [1] CRAN (R 4.0.3) #> xml2 1.3.2 2020-04-23 [1] CRAN (R 4.0.3) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.2) #> #> [1] /home/jn/R/x86_64-redhat-linux-gnu-library/4.0 #> [2] /usr/lib64/R/library #> [3] /usr/share/R/library ```
mtennekes commented 3 years ago

@Nowosad can you give me a trackback?

Nowosad commented 3 years ago

Traceback was very long, so I aggregated the original raster before plotting (r_stack2 = aggregate(r_stack, 8)). It is still long though:

> traceback() 16: stop(simpleError(msg, call = if (p <- sys.parent(1L)) sys.call(p))) 15: stopifnot(length(d) == length(dim(x[[1]]))) 14: dim.stars(x) 13: dim(x) 12: nrow(shps[[gt$shape.masterID]]) 11: plot_1(1L, list(tmLayer1 = list(varnames = list(by = NA, fill = NA, symbol.size = NA, symbol.col = NA, symbol.shape = NA, line.col = NA, line.lwd = NA, raster = NA, text.size = NA, text.col = NA), idnames = list(fill = NA, symbol = NA, line = NA, text = NA), treat_by_count = 1L, data_by = structure(1L, .Label = "___NA___", class = "factor"), nrow = NA, ncol = NA, panel.names = NA, along.names = NA, plot.order = "tm_tiles", any.legend = FALSE, col = "#FFFFFF00", lwd = 0.77203183762284, lty = "blank", alpha = NA, fill = NULL, xfill = NA, fill.legend.title = NA, fill.id = NA, fill.group = NA, fill.zindex = NA, fill.interactive = FALSE, line.lwd = NULL, xline = NA, xlinelwd = NA, line.col.legend.title = NA, line.lwd.legend.title = NA, line.id = NA, line.group = NA, symbol.size = NULL, xsize = NA, xcol = NA, xshape = NA, symbol.size.legend.title = NA, symbol.col.legend.title = NA, symbol.shape.legend.title = NA, symbol.id = NA, symbol.group = NA, text = NULL, xtext = NA, xtsize = NA, xtcol = NA, text.size.legend.title = NA, text.col.legend.title = NA, text.id = NA, text.group = NA, raster = NULL, xraster = NA, raster.legend.title = NA, raster.group = NA, tile.server = c("Esri.WorldGrayCanvas", "OpenStreetMap", "Esri.WorldTopoMap"), tile.alpha = c(1, 1, 1), tile.group = c(NA, NA, NA), tile.gtype = "base", tile.zindex = NA, tile.tms = c(FALSE, FALSE, FALSE)), tmLayer2 = list(npol = 264L, varnames = list( by = NA, fill = NA, symbol.size = NA, symbol.col = NA, symbol.shape = NA, line.col = NA, line.lwd = NA, raster = c("layer.1", "layer.2", "layer.3"), text.size = NA, text.col = NA), idnames = list( fill = NA, symbol = NA, line = NA, text = NA), treat_by_count = 3L, data_by = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = "___NA___", class = "factor"), nrow = NA, ncol = NA, panel.names = c("layer.1", "layer.2", "layer.3"), along.names = NA, plot.order = "tm_raster", any.legend = TRUE, col = "#FFFFFF00", lwd = 0.77203183762284, lty = "blank", alpha = NA, fill = NULL, xfill = NA, fill.legend.title = NA, fill.id = NA, fill.group = NA, fill.zindex = NA, fill.interactive = FALSE, line.lwd = NULL, xline = NA, xlinelwd = NA, line.col.legend.title = NA, line.lwd.legend.title = NA, line.id = NA, line.group = NA, symbol.size = NULL, xsize = NA, xcol = NA, xshape = NA, symbol.size.legend.title = NA, symbol.col.legend.title = NA, symbol.shape.legend.title = NA, symbol.id = NA, symbol.group = NA, text = NULL, xtext = NA, xtsize = NA, xtcol = NA, text.size.legend.title = NA, text.col.legend.title = NA, text.id = NA, text.group = NA, raster = c("#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#FECF66", "#FECF66", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#FECF66", "#FECF66", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#FECF66", "#FECF66", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#FECF66", "#FECF66", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#CC4C02", "#CC4C02", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#FECF66", "#FECF66", "#FECF66", "#F88B22", "#F88B22", "#F88B22", "#FECF66", "#FECF66", "#FECF66", "#FECF66"), raster.legend.labels = structure(c("0 to 50", "50 to 100", "100 to 150", "150 to 200"), align = NA), raster.legend.values = c(0, 50, 100, 150), raster.legend.palette = c("#FEF6BA", "#FECF66", "#F88B22", "#CC4C02"), raster.legend.misc = list(lwd = numeric(0)), raster.legend.hist.misc = list(values = c(104.046875, 104.375, 109.796875, 120.1875, 127.359375, 116.984375, 108.96875, 105.975, 112.984375, 121.0625, 147.15625, 163.171875, 166.828125, 144.703125, 119.734375, 107.9, 127.640625, 142.390625, 174.0625, 186.796875, 184.578125, 173.796875, 138.0625, 109.5, 128, 149.1875, 173.234375, 168.84375, 159.5625, 178.03125, 150.15625, 114.25, 114.015625, 132.625, 159.71875, 175.34375, 164.75, 158.0625, 133.75, 111.6, 114.484375, 129.765625, 154.578125, 166.625, 150.640625, 131.578125, 117.625, 107.7, 117.0625, 132.828125, 154.828125, 158.421875, 145.171875, 127.65625, 111.875, 104.85, 116.03125, 136.21875, 149.8125, 144.84375, 137.140625, 126.921875, 105.5, 102.4, 118.75, 132.421875, 142.921875, 131.984375, 120.703125, 109.28125, 100.234375, 98.85, 105.09375, 110.375, 111.46875, 115.640625, 108.265625, 98.203125, 96.078125, 95.925, 99.4107142857143, 100.892857142857, 100.875, 106.375, 99.9285714285714, 96.125, 94.7142857142857, 94.2571428571429), breaks = c(0, 50, 100, 150, 200), densities = NULL), raster.nonemptyFacets = c(TRUE, TRUE, TRUE), xraster = c("layer.1", "layer.2", "layer.3"), raster.legend.show = TRUE, raster.legend.title = "layer.1", raster.legend.is.portrait = TRUE, raster.legend.reverse = FALSE, raster.legend.z = 2, raster.legend.hist = FALSE, raster.legend.hist.title = "", raster.legend.hist.z = 2.5, raster.misc = list(is.OSM = FALSE, leaflet.server = NA, interpolate = FALSE), raster.nonemptyFacets = c(TRUE, TRUE, TRUE), raster.id = NA, raster.popup.vars = NULL, raster.interactive = NULL, raster.popup.format = structure(list(fun = NULL, scientific = FALSE, digits = NA, big.num.abbr = c(mln = 6, bln = 9), prefix = "", suffix = "", text.separator = "to", text.less.than = c("Less", "than"), text.or.more = c("or", "more"), text.align = NA, text.to.columns = FALSE), big.num.abbr.set = FALSE), raster.group = NA, raster.zindex = NA, tile.server = NULL, tile.alpha = NA, tile.group = NA, tile.tms = FALSE), tm_layout = list( unit = "metric", limits = c(facets.plot = 64, facets.view = 4 ), max.categories = 30, max.raster = c(plot = 1e+06, view = 1e+06 ), show.messages = TRUE, show.warnings = TRUE, output.format = "png", output.size = 49, output.dpi = 300, output.dpi.animation = 100, check.and.fix = FALSE, title = "", scale = 0.77203183762284, title.size = 1.00364138890969, bg.color = "#FFFFFF", aes.color = NULL, aes.palette = list(seq = "YlOrBr", div = "RdYlGn", cat = "Set3"), attr.color = "black", sepia.intensity = NULL, saturation = NULL, frame = "#000000", frame.lwd = 0.77203183762284, frame.double.line = FALSE, asp = NA, outer.margins = c(0.02, 0.02, 0.02, 0.02), inner.margins = c(0, 0, 0, 0), between.margin = 0.5, outer.bg.color = NULL, fontface = "plain", fontfamily = "", earth.boundary = FALSE, earth.boundary.color = "#000000", earth.boundary.lwd = 0.77203183762284, earth.datum = 4326, space.color = "#FFFFFF", legend.show = FALSE, legend.only = FALSE, legend.outside = TRUE, legend.outside.position = "right", legend.outside.size = 0.3, legend.position = NULL, legend.stack = "vertical", legend.just = c("left", "bottom"), legend.width = 0.4, legend.height = 0.9, legend.hist.height = 0.3, legend.hist.width = 0.4, legend.title.color = "#000000", legend.title.size = 0.849235021385125, legend.title.fontface = "plain", legend.title.fontfamily = "", legend.text.color = "#000000", legend.text.size = 0.540422286335988, legend.text.fontface = "plain", legend.text.fontfamily = "", legend.hist.size = 0.540422286335988, legend.format = list(fun = NULL, scientific = FALSE, digits = NA, big.num.abbr = c(mln = 6, bln = 9), prefix = "", suffix = "", text.separator = "to", text.less.than = c("Less", "than" ), text.or.more = c("or", "more"), text.align = NA, text.to.columns = FALSE), legend.frame = NA, legend.frame.lwd = 1, legend.bg.color = NA, legend.bg.alpha = 1, legend.hist.bg.color = NA, legend.hist.bg.alpha = 1, title.snap.to.legend = TRUE, title.position = c("left", "top" ), title.color = "#000000", title.fontface = "plain", title.fontfamily = "", title.bg.color = NA, title.bg.alpha = 1, panel.show = TRUE, panel.labels = c("layer.1", "layer.2", "layer.3"), panel.label.size = 0.77203183762284, panel.label.color = "#000000", panel.label.fontface = "plain", panel.label.fontfamily = "", panel.label.bg.color = "#CCCCCC", panel.label.height = 1.25, panel.label.rot = c(90, 0), main.title = "", main.title.size = 1.5, main.title.color = "#000000", main.title.fontface = "plain", main.title.fontfamily = "", main.title.position = "left", attr.outside = FALSE, attr.outside.position = "bottom", attr.outside.size = 0, attr.position = c("right", "bottom"), attr.just = c("left", "bottom"), basemaps = c("Esri.WorldGrayCanvas", "OpenStreetMap", "Esri.WorldTopoMap"), basemaps.alpha = c(1, 1, 1), overlays = NULL, overlays.alpha = 1, qtm.scalebar = TRUE, qtm.minimap = FALSE, qtm.mouse.coordinates = TRUE, alpha = 1, colorNA = NA, projection = structure(list( crsClass = "L.CRS.EPSG3857", code = NULL, proj4def = NULL, projectedBounds = NULL, options = structure(list(), .Names = character(0))), class = "leaflet_crs"), symbol.size.fixed = FALSE, dot.size.fixed = TRUE, text.size.variable = FALSE, bbox = NULL, set.bounds = FALSE, set.view = NA, set.zoom.limits = c(NA, NA), view.legend.position = "topright", control.position = c("left", "top"), leaflet.options = list(), aes.colors.light = c(fill = TRUE, borders = FALSE, symbols = TRUE, dots = FALSE, lines = FALSE, text = FALSE, na = TRUE, null = TRUE), aes.colors = c(fill = "grey85", borders = "grey40", symbols = "grey60", dots = "black", lines = "black", text = "black", na = "grey75", null = "grey95"), pc = list( sepia.intensity = 0, saturation = 1), design.mode = FALSE, earth.bounds = c(-180, -90, 180, 90), aes.color.light = c(fill = TRUE, borders = FALSE, symbols = TRUE, dots = FALSE, lines = FALSE, text = FALSE, na = TRUE, null = TRUE), attr.color.light = FALSE, legend.inside.box = FALSE, scale.extra = 0.77203183762284, asp_h = NULL, asp_w = NULL, panel.names = c("layer.1", "layer.2", "layer.3"), layer_vary = 2L, along = "", pp = 3, np = c(nrow = 1), calls = NULL, by = NULL, along = "", as.layers = FALSE, ncol = c(ncol = 3), nrow = c(nrow = 1), free.coords = TRUE, drop.units = TRUE, drop.empty.facets = TRUE, drop.NA.facets = FALSE, sync = NA, showNA = NA, textNA = "Missing", free.scales = FALSE, free.scales.fill = FALSE, free.scales.symbol.size = FALSE, free.scales.symbol.col = FALSE, free.scales.symbol.shape = FALSE, free.scales.text.size = FALSE, free.scales.text.col = FALSE, free.scales.line.col = FALSE, free.scales.line.lwd = FALSE, free.scales.raster = FALSE, inside.original.bbox = FALSE, scale.factor = 2, drop.shapes = TRUE, call = "free.scales", shp_name = c("dummy", "r_stack2"), shp_nr = c(0, 0), treat_as_by = TRUE, nrowcol = c(nrow = 1, ncol = 3), grid.show = FALSE, credits.show = FALSE, logo.show = FALSE, scale.show = FALSE, compass.show = FALSE, xlab.show = FALSE, ylab.show = FALSE, minimap.show = FALSE, mouse.show = FALSE, shape.id = c(1L, 3L), shape.nshps = 2L, shape.apply_map_coloring = FALSE, shape.is_raster_master = c(tm_shape = TRUE), shape.masterID = 2L, shape.master_crs = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), shape.crsSimple = TRUE, shape.orig_crs = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), shape.bbx_raw = structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1), class = "bbox", crs = structure(list( input = NA_character_, wkt = NA_character_), class = "crs")), shape.unit = "km", shape.bb_args = structure(list(), .Names = character(0)), shape.raster_facets_vars = list(structure(NA, max.value = NA, is.RGB = FALSE, to.Cat = FALSE), structure(NA, max.value = 255, is.RGB = FALSE, to.Cat = FALSE)), shape.bbx_cropped = structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1), crs = structure(list( input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), class = "bbox"), shape.masp = 1.03721923126461, shape.dasp = 1.8546511627907, shape.asp_ratio = 0.559253002437344, panel.mode = "one", shape.id = c(1L, 3L), shape.nshps = 2L, shape.apply_map_coloring = FALSE, shape.is_raster_master = c(tm_shape = TRUE), shape.masterID = 2L, shape.master_crs = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), shape.crsSimple = TRUE, shape.orig_crs = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), shape.bbx_raw = structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1), class = "bbox", crs = structure(list( input = NA_character_, wkt = NA_character_), class = "crs")), shape.unit = "km", shape.bb_args = structure(list(), .Names = character(0)), shape.raster_facets_vars = list(structure(NA, max.value = NA, is.RGB = FALSE, to.Cat = FALSE), structure(NA, max.value = 255, is.RGB = FALSE, to.Cat = FALSE)), shape.bbx_cropped = structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1), crs = structure(list( input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), class = "bbox"), shape.masp = 1.03721923126461, shape.dasp = 1.8546511627907, shape.asp_ratio = 0.559253002437344, shape.shps_lengths = c(tm_shape = 0L, tm_shape = 88L), shape.dw = 9.57, shape.dh = 5.16, shape.tasp = 1.8546511627907, shape.lasp = c(ncol = 0.431177701377774), shape.fpi = list( legH = 0, legW = 2.990625, attrH = 0, mainH = 0, pSH = 0.19300795940571, pSW = 0, legmar = c(0, 0, 0, 0.3), legmarx = 0.3, legmary = 0, attrmar = c(0, 0, 0, 0), attrmary = 0, mainmary = 0, xlabHin = 0, ylabWin = 0, xgridHin = 0, ygridWin = 0, between.margin.in = 0.077203183762284, dsh = c(nrow = 4.96699204059429), dsw = c(ncol = 2.14165621082514)), shape.sasp = 1.03721923126461, shape.bbx = structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1), class = "bbox", crs = structure(list( input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs")), shape.bboxes = list(structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1), class = "bbox", crs = structure(list( input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"))), shape.same_bbx = TRUE, shape.legend_pos = 2, shape.diff_shapes = FALSE, shape.inner.margins = c(ymin = 0, xmin = 0, ymax = 0, xmax = 0 ), shape.units = list(projection = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), unit = "km", to = 111.315376589325, projected = FALSE), ylabx = 4, ylaby = 5:8, xlabx = 5:12, xlaby = 9, attrx = 5:12, attry = 10, legy = 5:8, legx = 13, rowhs = c(0.02, 0.269970819693862, 0, 0, 0, 0.035908457563853, nrow = 0.384139903048423, 0, 0, 0, 0, 0.269970819693862, 0.02), colws = c(0.02, 0, 0, 0, 0, ncol = 0.214833653332512, 0.00774452000123225, 0, ncol = 0.214833653332512, 0.00774452000123225, 0, ncol = 0.214833653332512, 0.3, 0, 0.02), faceth = c(nrow = 0.384139903048423), facetw = c(ncol = 0.214833653332512), rowrange = 7, colrange = c(6, 9, 12), attr.between.legend.and.map = TRUE, xgridHnpc = 0, ygridWnpc = 0, xlabHnpc = 0, ylabWnpc = 0, panelw = 0, panelh = 0.035908457563853, between.margin.x = 0.00774452000123225, between.margin.y = 0.0143633830255412, gasp = 3.11165769379383, credits.text = NULL, credits.size = NULL, credits.col = NULL, credits.alpha = NULL, credits.align = NULL, credits.bg.color = NULL, credits.bg.alpha = NULL, credits.fontface = NULL, credits.fontfamily = NULL, credits.position = NULL, credits.just = NULL, credits.id = NULL, logo.file = NULL, logo.position = NULL, logo.just = NULL, logo.height = NULL, logo.width = NULL, logo.halign = NULL, logo.margin = NULL, logo.id = NULL)), list(), structure(list( dummy = NULL, r_stack2 = structure(list(layer.1 = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L), .Dim = c(x = 8L, y = 11L, band = 3L))), dimensions = structure(list(x = structure(list( from = 1, to = 8L, offset = 0, delta = 0.131147540983607, refsys = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), point = NA, values = NULL), class = "dimension"), y = structure(list( from = 1, to = 11L, offset = 1, delta = -0.0919540229885058, refsys = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), point = NA, values = NULL), class = "dimension")), raster = structure(list( affine = c(0, 0), dimensions = c("x", "y"), curvilinear = FALSE), class = "stars_raster"), class = "dimensions"), class = "stars", bbox = structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1 ), class = "bbox", crs = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs")), point.per = "feature", line.center = "midpoint", projected = FALSE)), info = list( shape.sasp = 1.03721923126461, shape.bbx = structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1 ), class = "bbox", crs = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs")), shape.bboxes = list(structure(c(xmin = 0, ymin = -0.0114942528735633, xmax = 1.04918032786885, ymax = 1), class = "bbox", crs = structure(list( input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"))), shape.same_bbx = TRUE, shape.legend_pos = 2, shape.diff_shapes = FALSE, shape.inner.margins = c(ymin = 0, xmin = 0, ymax = 0, xmax = 0 ), shape.units = list(projection = structure(list(input = "EPSG:4326", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), unit = "km", to = 111.315376589325, projected = FALSE))), 1.8546511627907, 1.03721923126461, c(ymin = 0, xmin = 0, ymax = 0, xmax = 0), 2, TRUE) 10: do.call(fun, args = list(i, gps[[i]], gal, shps, dasp, sasp, inner.margins.new, legend_pos, nx > 1)) 9: cellplot(rw, cl, e = do.call(fun, args = list(i, gps[[i]], gal, shps, dasp, sasp, inner.margins.new, legend_pos, nx > 1)), name = paste("multiple", i, sep = "_")) 8: (function (i, rw, cl) { cellplot(rw, cl, e = do.call(fun, args = list(i, gps[[i]], gal, shps, dasp, sasp, inner.margins.new, legend_pos, nx > 1)), name = paste("multiple", i, sep = "_")) })(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]) 7: mapply(function(i, rw, cl) { cellplot(rw, cl, e = do.call(fun, args = list(i, gps[[i]], gal, shps, dasp, sasp, inner.margins.new, legend_pos, nx > 1)), name = paste("multiple", i, sep = "_")) }, istart:iend, rep(gmeta$rowrange, each = mfcol, length.out = ni), rep(gmeta$colrange, times = mfrow, length.out = ni), SIMPLIFY = FALSE) 6: FUN(X[[i]], ...) 5: lapply(1:np, function(k) { if (progress) { setTxtProgressBar(pb, k/np) } if (k != 1) { grid.newpage() } if (dasp > 1) { cw <- dasp ch <- 1 } else { ch <- 1/dasp cw <- 1 } vpContainer <- viewport(width = unit(cw, "snpc"), height = unit(ch, "snpc")) pushViewport(vpContainer) grobBG <- if (gmeta$design.mode) { rectGrob(gp = gpar(fill = "yellow", col = NA), name = "bg_rect") } else if (is.na(gmeta$frame) && !gmeta$earth.boundary) { rectGrob(gp = gpar(fill = gmeta$bg.color, col = NA), name = "bg_rect") } else if (is.na(gmeta$frame) && gmeta$earth.boundary) { rectGrob(gp = gpar(fill = gmeta$space.color, col = NA), name = "bg_rect") } else if (!is.null(gmeta$outer.bg.color) && !is.na(gmeta$frame)) { rectGrob(gp = gpar(col = gmeta$outer.bg.color, fill = gmeta$outer.bg.color), name = "bg_rect") } else NULL vpGrid <- viewport(layout = grid.layout(nrw, ncl, widths = unit(gmeta$colws, "npc"), heights = unit(gmeta$rowhs, "npc")), name = "multiples_grid") pushViewport(vpGrid) grobBG2 <- if (gmeta$design.mode) { cellplot(2:(length(gmeta$rowhs) - 1), 2:(length(gmeta$colws) - 1), e = rectGrob(gp = gpar(fill = "green", col = NA), name = "bg_wo_outer")) } else NULL grobFacetBG <- if (gmeta$design.mode) { cellplot(4:(length(gmeta$rowhs) - 2), 3:(length(gmeta$colws) - 2), e = rectGrob(gp = gpar(fill = "brown", col = NA), name = "bg_facets_rect")) } else NULL grobMainBG <- if (gmeta$main.title[k] != "" && gmeta$design.mode) { cellplot(3, 3:(length(gmeta$colws) - 2), e = rectGrob(gp = gpar(fill = "gold", col = NA), name = "bg_main_rect")) } else NULL grobMain <- if (gmeta$main.title[k] != "") { cellplot(3, 3:(length(gmeta$colws) - 2), e = { margin <- convertWidth(unit(gmeta$main.title.size, "lines"), "npc", valueOnly = TRUE) * 0.25 main_pos <- gmeta$main.title.position main_align <- ifelse(is.character(main_pos), ifelse(main_pos %in% c("center", "centre"), "center", ifelse(main_pos == "left", "left", "right")), "left") main_pos <- ifelse(is.character(main_pos), ifelse(main_pos %in% c("center", "centre"), 0.5, ifelse(main_pos == "left", margin, 1 - margin)), main_pos) textGrob(gmeta$main.title[k], x = main_pos, just = main_align, gp = gpar(cex = gmeta$main.title.size, col = gmeta$main.title.color, fontface = gmeta$main.title.fontface, fontfamily = gmeta$main.title.fontfamily)) }, name = "main_title") } else NULL istart <- (k - 1) * pp + 1 iend <- min(istart + pp - 1, nx) ni <- iend - istart + 1 treeMults <- mapply(function(i, rw, cl) { cellplot(rw, cl, e = do.call(fun, args = list(i, gps[[i]], gal, shps, dasp, sasp, inner.margins.new, legend_pos, nx > 1)), name = paste("multiple", i, sep = "_")) }, istart:iend, rep(gmeta$rowrange, each = mfcol, length.out = ni), rep(gmeta$colrange, times = mfrow, length.out = ni), SIMPLIFY = FALSE) treeGridLabels <- if (external_grid_labels && gmeta$grid.show && any(gmeta$grid.labels.show)) { mapply(function(i, rw, cl) { if (multi_shapes) { proj <- bbxproj[[i]]$proj bbx <- bbxproj[[i]]$bbx } else { proj <- bbxproj$proj bbx <- bbxproj$bbx } gt <- gps[[i]]$tm_layout gTree(children = gList(if (gt$grid.labels.show[1]) cellplot((rw + 1), cl, clip = FALSE, e = plot_grid_labels_x(gt, scale = gt$scale), name = "gridLabelsX") else NULL, if (gt$grid.labels.show[2]) cellplot(rw, (cl - 1), clip = FALSE, e = plot_grid_labels_y(gt, scale = gt$scale), name = "gridLabelsY") else NULL), name = paste("gridLabels", i, sep = "_")) }, istart:iend, rep(gmeta$rowrange, each = mfcol, length.out = ni), rep(gmeta$colrange, times = mfrow, length.out = ni), SIMPLIFY = FALSE) } else NULL if (panel.mode == "both") { rowPanels <- lapply((1:mfrow), function(i) { cellplot(gmeta$rowrange[i], gmeta$rowpanelcol, e = gList(rectGrob(gp = gpar(fill = gmeta$panel.label.bg.color, lwd = gmeta$frame.lwd)), textGrob(panel.names[[1]][i], rot = gmeta$panel.label.rot[1], gp = gpar(col = gmeta$panel.label.color, cex = gmeta$panel.label.size, fontface = gmeta$panel.label.fontface, fontfamily = gmeta$panel.label.fontfamily)))) }) colPanels <- lapply((1:mfcol), function(i) { cellplot(gmeta$colpanelrow, gmeta$colrange[i], e = gList(rectGrob(gp = gpar(fill = gmeta$panel.label.bg.color, lwd = gmeta$frame.lwd)), textGrob(panel.names[[2]][i], rot = gmeta$panel.label.rot[2], gp = gpar(col = gmeta$panel.label.color, cex = gmeta$panel.label.size, fontface = gmeta$panel.label.fontface, fontfamily = gmeta$panel.label.fontfamily)))) }) } else if (panel.mode == "one") { colPanels <- mapply(function(i, rw, cl) { cellplot(rw, cl, e = gList(rectGrob(gp = gpar(fill = gmeta$panel.label.bg.color, lwd = gmeta$frame.lwd)), textGrob(panel.names[i], rot = gmeta$panel.label.rot[2], gp = gpar(col = gmeta$panel.label.color, cex = gmeta$panel.label.size, fontface = gmeta$panel.label.fontface, fontfamily = gmeta$panel.label.fontfamily)))) }, istart:iend, rep(gmeta$rowrange - 1, each = mfcol, length.out = ni), rep(gmeta$colrange, times = mfrow, length.out = ni), SIMPLIFY = FALSE) rowPanels <- NULL } else { rowPanels <- NULL colPanels <- NULL } if (!is.null(gp_leg)) { legPanel <- gList(cellplot(gmeta$legy, gmeta$legx, e = do.call(fun, args = list(1, gp_leg[[k]], gal, shps, dasp, sasp, inner.margins.new, legend_pos, nx > 1)), name = "outside_legend")) } else { legPanel <- NULL } if (!is.null(gp_attr)) { attrPanel <- gList(cellplot(gmeta$attry, gmeta$attrx, e = do.call(fun, args = list(1, gp_attr[[k]], gal, shps, dasp, sasp, inner.margins.new, legend_pos, nx > 1)), name = "outside_attr")) } else { attrPanel <- NULL } if (gmeta$xlab.show) { y <- unit(gmeta$xlab.nlines/2 + 0.2, "lines") xlabPanel <- gList(cellplot(gmeta$xlaby, gmeta$xlabx, e = textGrob(gmeta$xlab.text, rot = gmeta$xlab.rotation, y = y, gp = gpar(cex = gmeta$xlab.size, fontface = gmeta$fontface, fontfamily = gmeta$fontfamily)), name = "xlab")) } else { xlabPanel <- NULL } if (gmeta$ylab.show) { x <- unit(gmeta$ylab.nlines/2 + 0.2, "lines") ylabPanel <- gList(cellplot(gmeta$ylaby, gmeta$ylabx, e = textGrob(gmeta$ylab.text, rot = gmeta$ylab.rotation, x = x, gp = gpar(cex = gmeta$ylab.size, fontface = gmeta$fontface, fontfamily = gmeta$fontfamily)), name = "ylab")) } else { ylabPanel <- NULL } tree <- gTree(children = do.call("gList", c(list(grobBG, grobBG2, grobFacetBG, grobMainBG, grobMain), treeGridLabels, treeMults, rowPanels, colPanels, legPanel, attrPanel, xlabPanel, ylabPanel)), vp = vpGrid) grid.draw(tree) }) 4: plot_n(gm, "plot_1", nx, g$gps, gal, shps, gm$shape.dasp, gm$shape.sasp, gm$shape.inner.margins, gm$shape.legend_pos, g$gp_leg, g$gp_attr) 3: print_tmap(x = x, vp = vp, return.asp = return.asp, mode = mode, show = show, knit = knit, options = options, ...) 2: print.tmap(x) 1: (function (x, ...) UseMethod("print"))(x) <\details>
ailich commented 3 years ago

Going down to the CRAN release of stars (‘0.4.3’) fixes it for me

mtennekes commented 3 years ago

Ok, I found out that it is caused by a conflict the the github version of stars (at least newer than September 2020).

It may not be a bug in stars, but a different (improved) behavior.

In these code chunk (https://github.com/mtennekes/tmap/blob/master/R/pre_process_shapes.R#L212-L216) a (possibly multi-attribute) stars objects with possibly more dimensions than the raster ones (normally x and y) is converted to a stars object with 1 attribute, just the 2 x/y dimensions, and filled with integer values. At least, that is what I tried to achieve. But this doesn't work anymore, since I cannot overwrite a 3-dimensional array with a 2 dimensional matrix. I guess some checks have been added to prevent this.

@Nowosad do you know how to do this?

Nowosad commented 3 years ago

No, I do not. However, I would guess it is a result of a fairly recent change in stars (in the last few days).

Nowosad commented 3 years ago

See https://github.com/r-spatial/stars/issues/365 ?

mtennekes commented 3 years ago

@edzer A question about stars that should be fairly trivial: how do I slice a stars object such that I only keep the raster dimensions (normally x and y)? After that I want to replace the values by an integer sequence.

My old approach was something like this, which worked in earlier versions:

library(stars)
library(raster)
r = raster(volcano)
r_stack<- stack(r, focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=mean, na.rm=TRUE), focal(r, w=matrix(data = 1, nrow=3, ncol=3), fun=sd, na.rm=TRUE))
stars_obj<- st_as_stars(r_stack)

stars_obj[[1]] <- matrix(1L:(nrow(stars_obj)*ncol(stars_obj)), ncol = ncol(stars_obj), nrow = nrow(stars_obj))
attr(stars_obj, "dimensions") <- attr(stars_obj, "dimensions")[c("x", "y")]

I can use the tidyverse slice method, but I do not want to import dplyr in tmap, and I do not know how to filter multiple dimensions programmatically.

mtennekes commented 3 years ago

See r-spatial/stars#365 ?

It might be related to https://github.com/r-spatial/stars/issues/365, but it is certainly not related to https://github.com/r-spatial/stars/issues/364, since r_stack does not contain factor levels and it is not saved on disk.

edzer commented 3 years ago

For instance by

> stars_obj<- st_as_stars(r_stack)
> s = adrop(stars_obj[,,,1])
> s[[1]] = seq_len(prod(dim(s)))
> s
stars object with 2 dimensions and 1 attribute
attribute(s):
    layer.1    
 Min.   :   1  
 1st Qu.:1328  
 Median :2654  
 Mean   :2654  
 3rd Qu.:3980  
 Max.   :5307  
dimension(s):
  from to offset      delta refsys point values x/y
x    1 61      0  0.0163934     NA    NA   NULL [x]
y    1 87      1 -0.0114943     NA    NA   NULL [y]

The [[<-.stars method is indeed new (and now consistent with $<-.stars), and checks whether the array dimensions correspond to the dimensions meta-data attribute. So you can't simply change one of them (leaving an inconsistency).

edzer commented 3 years ago

I closed https://github.com/r-spatial/stars/issues/365 btw, with what I consider the solution. Solving it for on-disk grids needs help from someone with deep understanding of raster internals.

mtennekes commented 3 years ago

Thx! It should be fixed now.