[R-sig-Geo] help

Robert Hijmans r.hijmans at gmail.com
Mon Feb 2 12:10:03 CET 2009


I think you have to loop over time ( "i"  in your case, which
presumably is a variable in your environment ).

something like:

for (i in 1:length(dat[1,1,])) {
   vz<-as.vector(dat[,,i])
   oz<-interpp(vx,vy,vz,ox,oy,linear=TRUE)
   Kolkata[i]<-oz$z
}



On Mon, Feb 2, 2009 at 5:38 PM, Anwesha Chakrabarti <c.anwesha at gmail.com> wrote:
> hi;
> i just started using R and need to do the following.
> i want to plot weather data (which is in a .netCDF file).
> i was trying to plot some climate data for westbengal region and then i
> tried to interpolate the data for kolkata (which will be a subset of the
> oroginal data for westbengal).
>
> i tried the following commands
> graphics.off()
> library(ncdf)
> library(akima)
> ncdata<-open.ncdf("A2.TREFHT-gis.westbengal.nc")
> lon<-get.var.ncdf(ncdata,"lon")
> lat<-get.var.ncdf(ncdata,"lat")
> time<-get.var.ncdf(ncdata,"time")
> dat <- get.var.ncdf(ncdata,"TREFHT")
> Kolkata <- array(dim=length(time))
>  vx<-as.vector(matrix(lon,nrow=length(lon),ncol=length(lat)))
> vy<-as.vector(matrix(lat,nrow=length(lon),ncol=length(lat),byrow=TRUE))
> vz<-as.vector(dat[,,i])
>  ox<-as.vector(88)
> oy<-as.vector(22)
> oz<-interpp(vx,vy,vz,ox,oy,linear=TRUE)
> Kolkata[i]<-oz$z
>  Kolkata<-Kolkata-273
> plot(Kolkata,type="l")
>
> now the command are working fine but producing the plot for a single day
> only. whereas i want to plot the data for the entire time period and want a
> line diagram.
> so my question is how can i do that? please help.
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>




More information about the R-sig-Geo mailing list