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?

  • $\begingroup$ 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. $\endgroup$ Aug 28, 2019 at 20:37
  • $\begingroup$ @SemidiurnalSimon I've made an edit, how does it look? $\endgroup$
    – uhoh
    Aug 28, 2019 at 20:58
  • $\begingroup$ I'd suggest something like "How to read only parts of a netCDF file in R" or similar. $\endgroup$ Aug 28, 2019 at 21:26

1 Answer 1


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:


#load your area of interest

#read netCDF

#extract the data for your area of interest
pr_data_domain<-extract(pr_data, domain_shp)

#then you can transform this in a data frame and write it as a csv

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

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.