1

I'm trying to extract a single variable from a 3-dimensional netCDF file.

[1] "file blah.nc has 3 dimensions:"
[1] "longitude   Size: 200"
[1] "latitude   Size: 100"
[1] "time   Size: 2000"
[1] "------------------------"
[1] "file blah.nc has 1 variables:"
[1] "short temp[longitude,latitude,time]  Longname:temperature Missval:-9999"

Time's units are "days". I just want to get a single day in the middle of the dataset at time=t1 say. The manual seems to indicate that I should temp1 = get.var.ncdf(blah.nc, "temp", start=c(long1, lat1, t1)), but this gets all temperatures for all longs and lats until the ends of the arrays. I don't want to read the entire variable and then extract the desired value in R, I want the ncdf library to do it. get.var.ncdf doesn't take a end=c(long1+1, lat1+1, t1+1) argument as far as I can tell? So, how can I do this using ncdf?

0

1 Answer 1

1

You need the count argument:

temp1 = get.var.ncdf(blah.nc, "temp", start=c(long1, lat1, t1), count=c(2,2,2))

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.