ClimateImpactLab / downscaleCMIP6

Downscaling & bias correction of CMIP6 tasmin, tasmax, and pr for the R/CIL GDPCIR project
MIT License
128 stars 31 forks source link

How to access the data using R? #625

Open Freestyleyang opened 2 years ago

Freestyleyang commented 2 years ago

Hi there, Thank you for developing the downscaled CMIP6 dataset! Is it possible to access the data using R? Could you please share some example codes?

delgadom commented 2 years ago

Thanks for your question and interest!

Unfortunately, this looks like it's still tricky. zarr support for R is being worked on, but it looks like it's in it's early stages. See this issue on zarr-developers: https://github.com/zarr-developers/community/issues/18

There is an example of reading from the STAC collection with R here: https://github.com/microsoft/PlanetaryComputerExamples/blob/main/quickstarts/reading-stac-r.ipynb

One thing you could do is to download a subset of the data in python, save to netCDF or something with better R support, and then open it locally in R. You could read in the data with xarray as we show in the examples and then save to netcdf with xr.Dataset.to_netcdf, e.g.:

ds.to_netcdf("local_filepath.nc")

The access to the data is provided by https://github.com/microsoft/PlanetaryComputer, so that's a good place to go for general access & support questions.