[R-sig-Geo] Automate the extraction of climate variable at different time depths from netcdf in r

Barnabas Daru darunabas at gmail.com
Sun Sep 7 17:58:27 CEST 2014


Hi Robert,
Thanks very much for your suggestion.
I tried the code you provided and it work! Many thanks.
However, it tends to extract the SST values for all the points and for time periods including even the years that I don't desire. This means I will have to delete one-by-one, the values for the years that I do not desire and keep only the ones I want.
I thought there is a way I could simply ask R to print in one column, the extracted values associated with only the years for which point data is available.
Thanks and kind regards
Barnabas



  \-/
   /\
  /--|    
 /---/ Barnabas Daru
 |--/  PhD Candidate,
 \-/   African Centre for DNA Barcoding,
 /\    University of Johannesburg,
/--\   PO Box 524, Auckland Park, 2006,
|---\  Johannesburg, South Africa.
 \---\ Lab: +27 11 559 3477        
  \--| Mobile: +277 3818 9583
   \-/ Website: www.barnabasdaru.com
   /\        
  /--\ 
 
#…if you can think it, you can do it.
 




On Sep 7, 2014, at 5:23 AM, Robert J. Hijmans wrote:

> Barnabas, ,
> You can try something like this:
> 
> b <- brick("~sst.mnmean.nc", varname="sst")
> # loop over species, or combine all species into one data.frame?
> mydata <- read.csv("~Species one.csv")
> extract.mydata <- extract(b, mydata[,5:6])
> write.csv(extract.mydata, file = "Species_one_extracted.csv")
> 
> Robert


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list