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?

asked Sep 10, 2014 at 10:48
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))
answered Sep 11, 2014 at 0:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.