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

GDAL Access window out of range on read-in of stars_proxy #678

Closed
galenholt opened this issue Apr 15, 2024 · 2 comments
Closed

GDAL Access window out of range on read-in of stars_proxy #678

galenholt opened this issue Apr 15, 2024 · 2 comments

Comments

@galenholt
Copy link

I'm trying to read a stars_proxy object in as stars with st_as_stars , and it is failing with

GDAL Error 5: NETCDF:"path/to/file/MYD11A1.061_1km_aid0001.nc":lon: Access window out of range in RasterIO(). Requested (0,0) of size 1671x1567 on raster of 1671x1.

The proxy object shows the correct dimensions, here x = 1671 and y = 1567, but for some reason the conversion loses y.

I originally encountered this cropping very large files, but I seem to be able to replicate it with something smaller that reads in fine with proxy = FALSE but fails with proxy = TRUE in the example below.

This issue does not happen with all netcdfs I've tried, but I have had it happen with several from different sources. So it might be a netcdf issue, but seems to be a fairly common one.

I have tried a few versions of stars because I've read this specific file in successfully before, and it seems to work for 0.5-05 and below but not for 0.5-6 and above.

library(stars)

download.file("https://raw.githubusercontent.com/galenholt/example/main/MYD11A1.061_1km_aid0001.nc",
              destfile = 'MYD11A1.061_1km_aid0001.nc',
              method = 'curl')

# Works without proxy
t_np <- read_stars("MYD11A1.061_1km_aid0001.nc", sub = "LST_Day_1km", proxy = FALSE)

# Fails with proxy first
t_proxy <- read_stars("MYD11A1.061_1km_aid0001.nc", sub = "LST_Day_1km", proxy = TRUE)
t_p <- st_as_stars(t_proxy)

# But the proxy can see the right values in y
t_proxy

# Can read the proxy in for the first value in y
t1 <- st_as_stars(t_proxy[, 1:10, 1,])

# But not others
t2 <- st_as_stars(t_proxy[, 1:10, 2,])

sessionInfo() is

R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8 LC_MONETARY=English_Australia.utf8
[4] LC_NUMERIC=C LC_TIME=English_Australia.utf8

time zone: Australia/Sydney
tzcode source: internal

attached base packages:
[1] stats graphics grDevices datasets utils methods base

other attached packages:
[1] stars_0.6-5 sf_1.0-16 abind_1.4-5

loaded via a namespace (and not attached):
[1] e1071_1.7-14 magrittr_2.0.3 KernSmooth_2.23-22 parallel_4.3.3 classInt_0.4-10 cli_3.6.2
[7] grid_4.3.3 DBI_1.2.2 renv_1.0.3 proxy_0.4-27 class_7.3-22 compiler_4.3.3
[13] rstudioapi_0.16.0 tools_4.3.3 Rcpp_1.0.12 yaml_2.3.8 rlang_1.1.3 units_0.8-5

Thank you

@edzer edzer closed this as completed in cee624a Apr 16, 2024
@edzer
Copy link
Member

edzer commented Apr 16, 2024

Thanks, great report! Should work now,

@galenholt
Copy link
Author

yep, I can confirm that works. Thank you!

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

2 participants