4. degen in R13352.nc (rogue gallery #1)
- number: 4
- opened: 2019-01-24
- state when archived: closed
- url when archived: https://github.com/rgdal-dev/rasterwise/issues/4
- archived: 2026-11-06 (authors omitted; email addresses and reply headers redacted; non-ASCII transliterated)
Opening post
files <- fs::dir_ls("../rasterwise/extdata/", recursive = TRUE, glob = "*.nc")
x <- purrr::map(files, purrr::possibly(read_ncdf, NULL))
bad <- purrr::map_lgl(x, is.null)
sum(bad) ## 1 is bad, for some reason the 1-dim first dimension of /rasterwise/extdata/R13352.nc is
## dropped even is collapse = FALSE (not TRUE for basic other cases)
## e.g.
# nc <- create.nc("d.nc")
# dim.def.nc(nc, "a", 1)
# dim.def.nc(nc, "b", 2)
# dim.def.nc(nc, "c", 3)
# dim.def.nc(nc, "d", 1)
# var.def.nc(nc, "data", "NC_DOUBLE", c(0,1,2,3))
# var.put.nc(nc, "data", array(1, dim = c(1, 2, 3, 1)))
# close.nc(nc)
dim(var.get.nc(open.nc("d.nc"), "data", collapse = FALSE))
# 1, 2, 3, 1Why that no work in R13352.nc?
Comment 1 (2019-05-15)
because ncdf4 and RNetCDF drop the NC_CHAR dimension and return a vector of strings, and not padded to the dim length