> float lat(rlat, rlon) ; > lat:standard_name = "latitude" ; > lat:long_name = "latitude" ; > lat:units = "degrees_north" ; > float lon(rlat, rlon) ; > lon:standard_name = "longitude" ; > lon:long_name = "longitude" ; > lon:units = "degrees_east" ;
These two previous variables are grids of lat-lon values that correspond to the data. I nabbed a .ncdf file of runoff values from a site: library(ncdf) r = open.ncdf("runoff.SMHI.MPIB2.nc") dim(get.var.ncdf(r,"lat")) [1] 90 86 dim(get.var.ncdf(r,"lon")) [1] 90 86 so when you get the 90x86 grids of runoff values, the lat-long coordinates are the corresponding ones in the "lat" and "lon" variables. lon = get.var.ncdf(r,"lon") lat = get.var.ncdf(r,"lat") # get data for t = 1: t1 = get.var.ncdf(r,"runoff",start=c(1,1,1),count=c(90,86,1)) now you have three 90x86 matrices. To get (x,y,runoff) matrix, we just put them together, something like: library(sp) xyr = data.frame(cbind(as.vector(lat),as.vector(lon),as.vector(t1))) names(xyr)=c("lat","lon","runoff") coordinates(xyr)=~lon+lat spplot(xyr,"runoff") - shows how non-griddy the projection really is - it should look like a fan since now we are showing the data on true lat-long points, not the transformed rlat rlong points. The rlat and rlon variables are the grid coordinate system, which appears to be some non-standard conical projection. Climate scientists! Details: http://prudence.dmi.dk/public/DDC/areas.html Barry ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.