You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear all, I've created this issue since I have some questions/doubts regarding the behaviour of RasterIO. For example:
library(stars)
#> Loading required package: abind#> Loading required package: sf#> Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUEW<- st_bbox(c(
xmin=11.9264894188302, ymin=35.4930391676817,
xmax=15.6509648037934, ymax=38.8119746624118
), crs="OGC:CRS84")
(dt<- read_stars(
.x="C:/Users/user/OneDrive - Politecnico di Milano/data-NDVI/c_gls_NDVI300_202301010000_GLOBE_OLCI_V2.0.1.nc",
sub="NDVI"
))
#> NDVI,#> stars_proxy object with 1 attribute in 1 file(s):#> $NDVI#> [1] "[...]/c_gls_NDVI300_202301010000_GLOBE_OLCI_V2.0.1.nc:NDVI"#> #> dimension(s):#> from to offset delta refsys x/y#> x 1 120960 -180 0.002976 WGS 84 [x]#> y 1 47040 80 -0.002976 WGS 84 [y]#> time 1 1 2023-01-01 UTC NA POSIXct
Now, my understanding is that the input data (i.e. the .nc file) is an array-like object where the first two dimensions (i.e. x and y) have 120960 and 47040 elements, respectively, and we have only 1 time stamp. If I try to subset the region of interest, I get the following.
dt[W]
#> stars_proxy object with 1 attribute in 1 file(s):#> $NDVI#> [1] "[...]/c_gls_NDVI300_202301010000_GLOBE_OLCI_V2.0.1.nc:NDVI"#> #> dimension(s):#> from to offset delta refsys x/y#> x 64488 65740 -180 0.002976 WGS 84 [x]#> y 13840 14955 80 -0.002976 WGS 84 [y]#> time 1 1 2023-01-01 UTC NA POSIXct
Now, based on my understanding of the second vignette included in the package, I started trying to replicate a similar spatial filter using the RasterIO options and got the following error:
read_stars(
.x="C:/Users/user/OneDrive - Politecnico di Milano/data-NDVI/c_gls_NDVI300_202301010000_GLOBE_OLCI_V2.0.1.nc",
sub="NDVI",
RasterIO=list(
nXOff=64488,
nYOff=13840
)
)
#> Error in CPL_read_gdal(as.character(x), as.character(options), as.character(driver), : the dims contain negative values
Furthermore, when I specify also the size of the new objects that I would like to read, I get a different error
read_stars(
.x="C:/Users/user/OneDrive - Politecnico di Milano/data-NDVI/c_gls_NDVI300_202301010000_GLOBE_OLCI_V2.0.1.nc",
sub="NDVI",
RasterIO=list(
nXOff=64488,
nXSize=1253,
nYOff=13840,
nYSize=1116
)
)
#> Warning in CPL_read_gdal(as.character(x), as.character(options),#> as.character(driver), : GDAL Error 5: C:\Users\user\OneDrive - Politecnico di#> Milano\data-NDVI\c_gls_NDVI300_202301010000_GLOBE_OLCI_V2.0.1.nc: Access window#> out of range in RasterIO(). Requested (64487,13839) of size 1253x1116 on#> raster of 512x512.#> Error in eval(expr, envir, enclos): read failure
I’m even more confused now since I don’t understand why it says my raster is 512 x 512…
EDIT: I just noticed that a similar issue was already discussed in #678 but I still get an error even if I'm using the github version of the package. Sorry, but I didn't find that issue sooner. EDIT2: I also run some tests with read_ncdf but with, IMO, it also returns a confusing output (not necessarily related to the R package since it just complains about the CRS). I can add them here, but they probably deserve a separate issue so I don't mix too many things.
The text was updated successfully, but these errors were encountered:
Thanks for the clear example, yes this needs some looking into; the first two error messages are not really helpful (or should not occur). The last example does work when you specify the sub-dataset directly the way GDAL understands it (and gdalinfo would reveal):
read_stars(
.x='NETCDF:"c_gls_NDVI300_202007010000_GLOBE_OLCI_V2.0.1.nc":NDVI',
# sub = "NDVI",RasterIO=list(
nXOff=64488,
nXSize=1253,
nYOff=13840,
nYSize=1116
)
)
# stars object with 3 dimensions and 1 attribute# attribute(s), summary of first 1e+05 cells:# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's# NDVI -0.08 0.315 0.388 0.3909759 0.505 0.84 99668# dimension(s):# from to offset delta refsys x/y# x 64488 65740 -180 0.002976 WGS 84 [x]# y 13840 14955 80 -0.002976 WGS 84 [y]# time 1 1 2020-07-01 UTC NA POSIXct
Dear all, I've created this issue since I have some questions/doubts regarding the behaviour of RasterIO. For example:
Now, my understanding is that the input data (i.e. the .nc file) is an array-like object where the first two dimensions (i.e. x and y) have 120960 and 47040 elements, respectively, and we have only 1 time stamp. If I try to subset the region of interest, I get the following.
Now, based on my understanding of the second vignette included in the package, I started trying to replicate a similar spatial filter using the RasterIO options and got the following error:
Furthermore, when I specify also the size of the new objects that I would like to read, I get a different error
I’m even more confused now since I don’t understand why it says my raster is 512 x 512…
The .nc file used in this reprex is related to the NDVI data shared by CLMS: https://land.copernicus.eu/en/products/vegetation/normalised-difference-vegetation-index-v2-0-300m#download.
The file can be downloaded from the Provider’s manifest of Copernicus Land Monitoring Service at the following link: https://globalland.vito.be/download/manifest/ndvi_300m_v2_10daily_netcdf/manifest_clms_global_ndvi_300m_v2_10daily_netcdf_latest.txt
It corresponds to the first set of observations recorded during 2023 and the following is the direct link: https://globalland.vito.be/download/netcdf/ndvi/ndvi_300m_v2_10daily/2023/20230101/c_gls_NDVI300_202301010000_GLOBE_OLCI_V2.0.1.nc
Warning: each file listed in that txt file is approximately 1.5/2GB.
I’m sorry for the “hard-to-reproduce” bug, but I couldn’t replicate it with artificial data.
Created on 2024-10-05 with reprex v2.0.2
Session info
EDIT: I just noticed that a similar issue was already discussed in #678 but I still get an error even if I'm using the github version of the package. Sorry, but I didn't find that issue sooner.
EDIT2: I also run some tests with
read_ncdf
but with, IMO, it also returns a confusing output (not necessarily related to the R package since it just complains about the CRS). I can add them here, but they probably deserve a separate issue so I don't mix too many things.The text was updated successfully, but these errors were encountered: