Prajjwal,

I think this should work:

library(raster)
library(rgdal)

b <- brick("APHRO_MA_025deg_V1003R1.2002.nc<http://aphro_ma_025deg_v1003r1.2002.nc/>",
 var='precip')
Tamor <- readOGR(dsn="F:/Documents/Dropbox/Public/R/APHRO", layer=
"tamorbas")

v <- extract(b, Tamor)

Robert


On Mon, May 21, 2012 at 10:56 AM, Panday, Prajjwal <ppanday@clarku.edu>wrote:

> Hello
>
> I am trying to extract area-averaged mean from a netcdf file using a
> vector. Please see my code below. I cannot figure out the commands to
> extract the time series of the 'precip variable' using the shapefile
> 'tamorbas'.
>
> Thanks,
> Prajjwal
> -------------------------------------------------------------------------
> require(ncdf)
> library(ncdf)
> require(rgdal)
> library(rgdal)
> library(raster)
>
> # Read netCDF file
> ncfile <- "APHRO_MA_025deg_V1003R1.2002.nc"
>
> #Open netCDF file
> nc <- open.ncdf(ncfile, missing="TRUE")
>
> print(nc)
> # Read in variables of netCDF file.
> time <- get.var.ncdf(nc,varid='time')
> longitude <- get.var.ncdf(nc,varid='longitude')
> latitude <- get.var.ncdf(nc,varid='latitude')
> precip <- get.var.ncdf(nc, varid='precip')
>
> # Read in shapfile
> Tamor <- readOGR(dsn="F:/Documents/Dropbox/Public/R/APHRO", layer=
> "tamorbas")
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

