Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatrasters won't plot #1412

Closed
qldsleo opened this issue Jan 29, 2024 · 6 comments
Closed

Spatrasters won't plot #1412

qldsleo opened this issue Jan 29, 2024 · 6 comments

Comments

@qldsleo
Copy link

qldsleo commented Jan 29, 2024

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!

@kadyb
Copy link
Contributor

kadyb commented Jan 29, 2024

Maybe it's related to the change in #1088 (comment)?

@qldsleo
Copy link
Author

qldsleo commented Jan 29, 2024

Potentially. Do you know how I would be able to force it to read from the actual data instead of the overviews?

@rhijmans
Copy link
Member

Can you share, if need be privately, an example file?

@kadyb
Copy link
Contributor

kadyb commented Jan 31, 2024

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.

@kadyb
Copy link
Contributor

kadyb commented Jun 24, 2024

Sorry @rhijmans for bothering you, but could you look into this issue when you find some free time?

@rhijmans
Copy link
Member

Sorry that it took me so long. I now get

library("terra")
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))
#   user  system elapsed 
#   0.53    0.11    0.89 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants