Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active March 4, 2025 11:26
Show Gist options
  • Save mdsumner/a9e74531cafce071de9b96588b3b9975 to your computer and use it in GitHub Desktop.
Save mdsumner/a9e74531cafce071de9b96588b3b9975 to your computer and use it in GitHub Desktop.

https://rstats.me/@mdsumner/114103904777240036

I've used HDF5 here because NETCDF can't do this on windows. On linux probably best to use "NETCDF:{dsn}:time".

(r <- terra::rast("HDF5:\"/vsicurl/https://www.ncei.noaa.gov/data/sea-surface-temperature-optimum-interpolation/v2.1/access/avhrr/198109/oisst-avhrr-v02r01.19810901.nc\"://time"))
class       : SpatRaster 
dimensions  : 1, 1, 1  (nrow, ncol, nlyr)
resolution  : 1, 1  (x, y)
extent      : 0, 1, 0, 1  (xmin, xmax, ymin, ymax)
coord. ref. :  
source      : https://oisst-avhrr-v02r01.19810901.nc://time 
varname     : time 
name        : time 
Warning message:
[rast] unknown extent 

terra::values(r)
     time
[1,] 1339

 r@pntr$metadata(1L)
[[1]]
[1] "CLASS=DIMENSION_SCALE"                "long_name=Center time of the day"     "NAME=time"                            
[4] "REFERENCE_LIST="                      "units=days since 1978-01-01 12:00:00"
[6] "_Netcdf4Dimid=0"                     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment