1

i am trying to extract specific data from an .nc file

my nc file has the following variables hur-relative humidity lat-latitudes lon-longitudes time-time plev-pressure levels

so i want to get the data of relative humidity for a specific plev and specific time

library(ncdf)
ncin<-open.ncdf("akhil.nc")
hur.array<-get.var.ncdf(ncin,"hur")
 error: cannot allocate 2.1 gb vector

as you can see the hur is to big so is there any way to directly specify the plev values and time values directly into the get.var.ncdf() function so has to reduce the vector size

i am new to ncdf files

1
  • Welcome to GIS SE! As a new user please take the Tour to learn about our focussed Q&A format.
    – PolyGeo
    Commented Nov 15, 2015 at 5:36

2 Answers 2

1

You can use functions in the raster package to avoid this problem

library(raster)
b <- brick("akhil.nc", var="hur")
b
0

Yes. Read the help on the get.var.ncdf(nc, varid=NA, start=NA, count=NA, verbose=FALSE, signedbyte=TRUE, forcevarid=NA) function with:

?get.var.ncdf

and use the start=c(1,3,5,7,1...), count=c(1,1,1,1,-1,....) parameters appropriate to your dataset.

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.