metno / esd

An R-package designed for climate and weather data analysis, empirical-statistical downscaling, and visualisation.
87 stars 30 forks source link

Retrieving data from 150 E to 160 W from netCDF files. #261

Closed javakh closed 2 years ago

javakh commented 2 years ago

Dear all, I wish to know that how can I retrieve data from 150 E to 160 W. If I use retrieve(.........,lon=c(150,-160)) [using negative for west], it is throwing an error. If I use retrieve(.........,lon=c(-150,160)), it is giving the region from 160W to 0 then 0 to 150E, the whole region, not the region I want to use. Please suggest.

brasmus commented 2 years ago

Here is one way to do it:

slp0 <- retrieve("~/Downloads/slp.mon.mean.nc")       ## Read the whole data set
lon(slp0)                            ## Check the longitudes
slp0 <- g2dl(slp0)              ## Transform Greenwich to Date-Line centering
lon(slp0)                            ## Check the longitudes again
slpx <- subset(slp0,is=list(lon=c(160,200),lat=c(-90,90)))    ## Subset 160E-160W (=200E)
map(slpx)                          ## Show the extracted data

image

javakh commented 2 years ago

Thank you so much for the solution. It is working.