[R-sig-Geo] getting data from an nc file

Roy Mendelssohn - NOAA Federal roy@mende|@@ohn @end|ng |rom no@@@gov
Thu Nov 10 04:31:59 CET 2022


Unfortunately you need to register to look at one of those files,  but what I could dig up on the internet suggest the data are on x,y coordinates.  You can find that just giving the command

nc_data 

or for more complete info

str(nc_data)

Also since they say they follow the CF conventions,  so that printout should contain information about the coordinate system.  I can't offhand find the description except a comment somewhere to be careful because of a use fo a different datum.  

HTH,

-Roy

> On Nov 9, 2022, at 2:53 AM, Nick Wray <nickmwray using gmail.com> wrote:
> 
> Hello
> 
> I am trying to get rainfall data from the UK chess-met site
> 
> https://catalogue.ceh.ac.uk/datastore/eidchub/2ab15bf0-ad08-415c-ba64-831168be7293/precip/
> 
> and here there are a large number of nc files eg
> 
> "chess-met_precip_gb_1km_daily_20150101-20150131.nc"
> 
> I’ve found various sources on the net for opening nc files, and getting the
> data but when I try instructions like
> 
> nc_data<-nc_open("chess-met_precip_gb_1km_daily_20150101-20150131.nc")
> 
> lon <- ncvar_get(nc_data, "lon")
> 
> lon
> 
> 
> 
> the code works but all I get is a series of element numbers and no data:
> 
> [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]     [,9]
> [,10]    [,11]    [,12]
> 
>          [,13]    [,14]    [,15]    [,16]    [,17]    [,18]    [,19]
> [,20]    [,21]    [,22]    [,23]    [,24]
> 
> 
> 
> And similarly for latitude
> 
> But if I open the nc file as a raster I get a raster precipitation plot of
> Great Britain, which rather suggests that the lat and long values are in
> there somewhere
> 
> Can anyone help with getting the actual data sets out of an nc file?
> 
> Thanks Nick Wray
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new street address***
110 McAllister Way
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn using noaa.gov www: https://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.



More information about the R-sig-Geo mailing list