Skip to content

Commit 6f2f07c

Browse files
committed
error if no subdatasets are found
1 parent 1cce845 commit 6f2f07c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

R/read.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
maybe_normalizePath = function(.x, np = FALSE) {
2-
prefixes = c("NETCDF:", "HDF5:", "HDF4:", "HDF4_EOS:", "SENTINEL2_L1", "SENTINEL2_L2", "GPKG:", "/vsi", "http://", "https://")
2+
prefixes = c("ZARR:", "NETCDF:", "HDF5:", "HDF4:", "HDF4_EOS:", "SENTINEL2_L1", "SENTINEL2_L2", "GPKG:", "/vsi", "http://", "https://")
33
has_prefix = function(pf, x) substr(x, 1, nchar(pf)) == pf
44
if (is.function(.x) || !np || any(sapply(prefixes, has_prefix, x = .x)))
55
.x
@@ -197,6 +197,8 @@ read_stars = function(.x, sub = TRUE, ..., options = character(0),
197197
if (length(data$bands) == 0) { # read sub-datasets: different attributes
198198
sub_names = split_strings(data$sub) # get named list
199199
sub_datasets = sub_names[seq(1, length(sub_names), by = 2)]
200+
if (length(sub_datasets) == 1 && is.na(sub_datasets[1]))
201+
stop("cannot derive subdataset names from data source: please provide manually")
200202
# sub_datasets = gdal_subdatasets(x, options)[sub] # -> would open x twice
201203

202204
# FIXME: only tested for NetCDF:

0 commit comments

Comments
 (0)