Skip to content

nchar if test error on length > 1 (vsicurl netcdf) #2036

@mdsumner

Description

@mdsumner

With this file (attached) print works fine locally:

rast("~/SEA_SURFACE_HEIGHT_mon_mean_2014-12_ECCO_V4r4_latlon_0p50deg.nc")
class       : SpatRaster 
size        : 360, 720, 3  (nrow, ncol, nlyr)
resolution  : 0.5, 0.5  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) 
sources     : SEA_SURFACE_HEIGHT_mon_mean_2014-12_ECCO_V4r4_latlon_0p50deg.nc:SSH  
              SEA_SURFACE_HEIGHT_mon_mean_2014-12_ECCO_V4r4_latlon_0p50deg.nc:SSHIBC  
              SEA_SURFACE_HEIGHT_mon_mean_2014-12_ECCO_V4r4_latlon_0p50deg.nc:SSHNOIBC  
varnames    : SSH (Dynamic sea surface height anomaly) 
              SSHIBC (The inverted barometer (IB) correction to sea surface height due to atmospheric pressure loading) 
              SSHNOIBC (Sea surface height anomaly without the inverted barometer (IB) correction) 
names       : SSH, SSHIBC, SSHNOIBC 
unit        : m 
time        : 2014-12-16 12:00:00 UTC

but via vsicurl there's a problem with the subdataset string parsing (it doesn't affect connect and read):

SEA_SURFACE_HEIGHT_mon_mean_2014-12_ECCO_V4r4_latlon_0p50deg.zip

Discovered with this (which requires GDAL_HTTP_HEADER_FILE or GDAL_HTTP_HEADERS set with an earthdata "Authorization: Bearer .." token.

library(terra)
url <- "https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/ECCO_L4_SSH_05DEG_MONTHLY_V4R4/SEA_SURFACE_HEIGHT_mon_mean_2014-12_ECCO_V4r4_latlon_0p50deg.nc"
r <- rast(url, subds = 1,  vsi = TRUE)
r
Error in if (nchar(r) > n) { : the condition has length > 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions