Predict GPP sample R code


Hi there,

Like a user before me, I am mostly familiar with R. To get a sense for how to access the cube data I am replicating the code available in the jupyter notebook “gpp-prediction-from-air-temp-and-surface-moisture.ipynb”. However I’ve run into an error because for a single cell the read.cube function returns a list object with different dimensions for time (length 1702) and RS variables (length 444). That means that when I try to convert this list into a dataframe I get an error.

I’m using the ESDCv1.0.2/esdc-31d-1deg-1x180x360-1.0.2 cube.

Below the warnings and error messages:

cubepath <- “/home/jovyan/work/datacube/ESDCv1.0.2/esdc-31d-1deg-1x180x360-1.0.2”
cube <- open.cube(cubepath)
Warning message in .parseConfigFile(cubepath):
“NAs introduced by coercion”

Warning message in unclass(e1) + unclass(e2):
“longer object length is not a multiple of shorter object length”
List of 6
time : POSIXct[1:1702], format: "1980-01-01" "1980-01-09" ... longitude : num 50.5
latitude : num 49.5 gross_primary_productivity: num [1, 1, 1:444] NA NA NA NA NA NA NA NA NA NA …
air_temperature_2m : num [1, 1, 1:444] NA NA NA NA NA NA NA NA NA NA ... surface_moisture : num [1, 1, 1:444] NA NA NA NA NA NA NA NA NA NA …


Error in data.frame(time = x$time, gpp = as.vector(x$gross_primary_productivity), : arguments imply differing number of rows: 1702, 444

  1. data.frame(time = x$time, gpp = as.vector(x$gross_primary_productivity),
    . tair = as.vector(x$air_temperature_2m), moist = as.vector(x$surface_moisture))
  2. stop(gettextf(“arguments imply differing number of rows: %s”,
    . paste(unique(nrows), collapse = ", ")), domain = NA)

Thank you for any help regarding this issue,



Dear Jorge,

thanks for reporting this. It looks like the reading software is not compatible with the monthly datacube. However, using the 8daily time resolution should work, at least this worked for me:


cubepath <- '/home/jovyan/work/datacube/ESDCv1.0.2/esdc-8d-0.25deg-46x90x90-1.0.2/'
cube <- open.cube(cubepath)



Bear also in mind that the support for R is only experimental and might drop in the future. The main reason is that we will use the zarr format as the datacube storage starting with ESDCv2.0 and there is no R package yet that lets you read these datasets.

So we can hope that someone implements this . Alternatively, if there is strong demand I might test if it is feasible to get basic reading capabilities by making a shallow z5 wrapper through Rcpp.