Problem to retrieve/plot selected bands in a stars proxy object
Thanks for the clear report, Lo?c; this should now be fixed in the version on github.
On 14/09/2021 14:55, Lo?c Val?ry wrote:
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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics Heisenbergstrasse 2, 48151 Muenster, Germany Phone: +49 251 8333081