Sudip Acharya
Sudip Acharya

Reputation: 1

Extract the data from NC file using R studio

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

Upvotes: 0

Views: 495

Answers (2)

ClimateUnboxed
ClimateUnboxed

Reputation: 8077

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

Upvotes: 0

Robert Hijmans
Robert Hijmans

Reputation: 47091

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).

Upvotes: 1

Related Questions