Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active February 17, 2025 23:55
Show Gist options
  • Save mdsumner/e2bf4a32e8985562896821d1c29dcd42 to your computer and use it in GitHub Desktop.
Save mdsumner/e2bf4a32e8985562896821d1c29dcd42 to your computer and use it in GitHub Desktop.

with stars (uses GDAL MULTIDIM)

## note we have to inner-quote the string (I think ZARR driver needs some attention here)
 dsn <- "ZARR:\"/vsicurl/https://mur-sst.s3.us-west-2.amazonaws.com/zarr-v1\""
library(stars)
read_mdim(dsn, proxy = TRUE, bounds = FALSE, variable = "analysed_sst")
stars_proxy object with 1 attribute in 1 file(s):
$analysed_sst
[1] "[...]/zarr-v1"

dimension(s):
     from    to     offset  delta refsys                                    values x/y
lon     1 36000         NA     NA     NA [-179.995,-179.985),...,[179.995,180.005) [x]
lat     1 17999         NA     NA     NA     [-89.995,-89.985),...,[89.985,89.995) [y]
time    1  6443 2002-06-01 1 days   Date                                      NULL    


@mdsumner
Copy link
Author

to actually get data with BLOSC encoding we need Rarr

##BiocManager::install('Rarr')

so then

sst <- g$get_item("analysed_sst")
sst$get_shape()
# [1]  6443 17999 36000
sst$get_compressor()
<BloscCodec>
  Inherits from: <Codec>
  Public:
    blocksize: 0
    clevel: 5
    clone: function (deep = FALSE)
    cname: lz4
    decode: function (buf, zarr_arr)
    encode: function (buf, zarr_arr)
    get_config: function ()
    initialize: function (cname = "lz4", clevel = 5, shuffle = TRUE, blocksize = NA,
    shuffle: 1


## don't get this yet
##sst$get_item(list(slice(1), slice(1, 10), slice(1:10)))

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