[R-sig-Geo] Problem to retrieve/plot selected bands in a stars proxy object

Loïc Valéry |v@|ery @end|ng |rom out|ook@|r
Tue Sep 14 14:55:02 CEST 2021


Dear list members,

I hope this message finds you well.
I submit to you a problem with which I have been struggling for several days without finding the beginning of a solution.

I would like to select some bands of a 'stars proxy' object that I have previously created by merging two images with the function read_stars(c(image1, image2), proxy = true, along = "band") in order to plot them.

My problem is that R returns the following error message when trying to plot the selected bands:
Error in x[[i]][, , 10:12, , drop = FALSE] : subscript out of bounds

Here is a short REPREX:
library(stars)
tif_1 <- system.file("tif/L7_ETMs.tif", package = "stars")
tif_2 <- system.file("tif/L7_ETMs.tif", package = "stars")

tif_merge <- read_stars(c(tif_1,tif_2), proxy = TRUE, along = "band")

plot(tif_merge[,,,10:12], rgb = 1:3)
#> Error in x[[i]][, , 10:12, , drop = FALSE]: indice hors limites



I guess the problem is that the "tif_merge" object has different dimensions before and after the promise evaluation:

dim(tif_merge)
#>    x    y band 
#>  349  352   12

dim(st_as_stars(tif_merge))
#>       x       y    band new_dim 
#>     349     352       6       2

However, this did not help me to find any solution!

Thank you in advance for your help.
Cheers,
Loïc



More information about the R-sig-Geo mailing list