ncdf_cube

Read a data cube from an existing netCDF file

Description

Create a proxy data cube from a netCDF file that has been created using write_ncdf. This function does not read cubes from arbitrary netCDF files and can be used e.g., to load intermediate results and/or plotting existing netCDF cubes on disk without doing the data cube creation from image collections.

Usage

ncdf_cube(path, chunking = NULL, auto_unpack = TRUE)

Arguments

Argument Description
path path to an existing netCDF file
chunking custom chunk sizes to read form the netCDF file; defaults to using chunk sizes from the netCDF file
auto_unpack logical; automatically apply offset and scale when reading data values

Value

a proxy data cube object

Note

This function returns a proxy object, i.e., it will not start any computations besides deriving the shape of the result.

Examples

# create image collection from example Landsat data only 
# if not already done in other examples
if (!file.exists(file.path(tempdir(), "L8.db"))) {
  L8_files <- list.files(system.file("L8NY18", package = "gdalcubes"),
                         ".TIF", recursive = TRUE, full.names = TRUE)
  create_image_collection(L8_files, "L8_L1TP", file.path(tempdir(), "L8.db"), quiet = TRUE) 
}

L8.col = image_collection(file.path(tempdir(), "L8.db"))
v = cube_view(extent=list(left=388941.2, right=766552.4, 
              bottom=4345299, top=4744931, t0="2018-04", t1="2018-06"),
              srs="EPSG:32618", nx = 497, ny=526, dt="P1M")


ncfile = write_ncdf(select_bands(raster_cube(L8.col, v), c("B02", "B03", "B04")))
ncdf_cube(ncfile)
A data cube proxy object

Dimensions:
         low       high count       pixel_size chunk_size
t 2018-04-01 2018-06-30     3              P1M          1
y    4345299    4744931   526 759.756653992395        384
x   388941.2   766552.4   497 759.781086519115        384

Bands:
  name offset scale nodata unit
1  B02      0     1    NaN     
2  B03      0     1    NaN     
3  B04      0     1    NaN