terra
terra copied to clipboard
Spatrasters won't plot
Hello,
I'm having issues plotting large cloud optimised geotiffs using terra. I've just updated R to version 4.3.2 and was previously using 4.0.5. I didn't have any issues plotting the geotiffs using the old R version. Now it won't plot and remains processing indefinitely.
This is my code: library(terra); library(paletteer) setwd() r_files = list.files(pattern='.tif', full.names=T) r = rast(r_files[c(1,5,3,4,6,2)]) # reorder names(r) = c('0-5 cm', '5-15 cm', '15-30 cm', '30-60 cm','60-100 cm', '100-200 cm') plot(r, col=paletteer_c('grDevices::Spectral', 30), box=F, range=c(0,90), axes=F)
plot(r[[1]]) won't even work. Neither will reducing the cells using maxcells. Any help would be great.
Thanks!
Maybe it's related to the change in https://github.com/rspatial/terra/issues/1088#issuecomment-1512422144?
Potentially. Do you know how I would be able to force it to read from the actual data instead of the overviews?
Can you share, if need be privately, an example file?
In the case below I see significant difference in plotting time:
library("terra")
gdal() # "3.7.2"
# Size is 10980, 10980
# Overviews: 5490x5490, 2745x2745, 1373x1373, 687x687
url = "/vsicurl/https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/55/G/DM/2023/12/S2A_55GDM_20231230_0_L2A/B02.tif"
x = terra::rast(url)
system.time(plot(x, maxcell = 10000))
#> user system elapsed
#> 7.09 3.91 50.50
y = stars::read_stars(url, proxy = TRUE)
system.time(plot(y, downsample = 10))
#> user system elapsed
#> 0.42 0.03 3.03
Edit: I tested this on another configuration and it seems that this problem doesn't occur in the old version of GDAL 3.0.4.
Sorry @rhijmans for bothering you, but could you look into this issue when you find some free time?