I have download ERA5 netCDF file in order to get precipitation monthly/daily rates for 11 years. But I have realized, there is no option to select my area of interest. It seems it is a big file to handle.

However, I am currently using R language and but still in the basic level.

My question is about if there is anyway to extract precipitation values for a certain area?

• Please edit your title to reflect the actual question. To answer, there is almost certainly a way in R to read just a part of a netCDF file - but I'm not enough of an R user to tell you what it is. Hopefully somebody will come along and aswer. Aug 28 '19 at 20:37
• @SemidiurnalSimon I've made an edit, how does it look?
– uhoh
Aug 28 '19 at 20:58
• I'd suggest something like "How to read only parts of a netCDF file in R" or similar. Aug 28 '19 at 21:26

There are two ways to get this done:

1- you can select the specific domain of interest when downloading the files. This is highly preferred when you have to download a large number of variables and years. ERA5 netCDF are offered in two different formats: either at hourly time steps, or at monthly averages (see this). If you need a sub-monthly time steps the global files for many variables for long time periods are extremely heavy in terms of disk space. You could set up a python script to download the data selecting only the domain by following a procedure like the one suggested in this nice post by Reto Stauffer (of course there are other ways to do this).

2- you can download the global netCDF of the variable and year under consideration ad use a software to extract your domain of interest. One of the most efficient systems to do that is using the Climate Data Operator CDO. you could use the sellonlatbox with a command like

cdo sellonlatbox,LON1,LON2,LAT1,LAT2 Input_file_Name.nc Output_file_Name.nc


Or you could use R, as for your case, doing something like:

library(raster)
library(rgdal)

setwd("path_domain_shapefile")


As reference for basic operations with spatial data in R, I would suggest this introduction guide.