I have the NC file with 0.5 resolution containing yearly PDSI index from 1900 to 2013 of globe. how can I get the one value for each year for entire Europe/Asia/America. thanks a lot
Asked
Active
Viewed 216 times
0
-
Have you tried the `library(ncdf4)`? – Martin Gal Aug 28 '21 at 15:01
-
Write nico clearer. For me, an NC file means a program for numerical machines. Give as an example. Generally speaking, if the file is in text format then: 1. Load it using the `readr` package 2. Process it using `dplyr` 3. Visualize using `ggplot2` You can find all these packages in the `tidyverse`. – Marek Fiołka Aug 28 '21 at 18:15
-
If you show the code you are using, starting with `library` calls to load the required packages, we might be able to help you move forward from wherever you are getting stuck. – IRTFM Aug 28 '21 at 18:26
-
sorry NC means ncdf file. – Sudip Acharya Aug 28 '21 at 18:27
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 28 '21 at 21:03
2 Answers
1
You can use the extract
or zonal
methods in the terra
package (or the older raster
package). For a more detailed answer you should ask a better question, that shows what you have tried, and where exactly you get stuck. If you do not know where to start, perhaps begin with this tutorial; and you can also consult the existing questions on this site (search for raster, extract, ncdf).

Robert Hijmans
- 40,301
- 4
- 55
- 63
0
I'm a little confused by the language requirements as you have R-studio in the title but tagged the question with cdo.
If you are happy to use cdo, you can cut out a region of choice with
cdo sellonlatbox,lon1,lon2,lat1,lat2 in.nc out.nc
You can then spatially average this file with
cdo fldmean in.nc out.nc
you can combine these two using piping
cdo fldmean -sellonlatmean,lon1,lon2,lat1,lat2 in.nc out.nc

ClimateUnboxed
- 7,106
- 3
- 41
- 86