0

I have 6 large rasters of a soil property and I wish to plot them using facet_wrap. Each of these raster represent a different depth interval for the same area and the same property. I usually load my raster from my hard drive but this time I load them from an online link. The following code works when loading my data from my hard drive, but doesn't when loading my data from the link online.

Here is a reproducible example of my error:

library(stars)
library(ggplot2

##### Access the COG directly from the DataStore and Plot it #######
list_ras <- c("SOC_000_005_EV_N_P_AU_TRN_N_20220727.tif",
              "SOC_005_015_EV_N_P_AU_TRN_N_20220727.tif",
              "SOC_015_030_EV_N_P_AU_TRN_N_20220727.tif",
              "SOC_030_060_EV_N_P_AU_TRN_N_20220727.tif",
              "SOC_060_100_EV_N_P_AU_TRN_N_20220727.tif",
              "SOC_100_200_EV_N_P_AU_TRN_N_20220727.tif")
ras <- read_stars(paste0('/vsicurl/https://esoil.io/TERNLandscapes/Public/Products/TERN/SLGA/SOC/', list_ras), along = 'depth')

names(ras$attr) <- c("0-5 cm", "5-15 cm", "15-30 cm", 
                     "30-60 cm", "60-100 cm", "100-200 cm")

ggplot() +
  geom_stars(data = ras, downsample = 100) + 
  facet_wrap(~depth)

And I get the error:

Error in attributes(.Data) <- c(attributes(.Data), attrib) : 
 dims [product 197152] do not match the length of object [1182912]

I have tried even more basic plotting but it always gives me a similar error. It seems that there is a problem with one dimension because 1182912/197152 = 6, i.e. my number of rasters.

1 Answers1

0

It is now solved by the stars packager maintainer, see: https://github.com/r-spatial/stars/issues/561