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

ani jaya g@@@uu| @end|ng |rom gm@||@com
Thu Nov 10 02:49:05 CET 2022


Maybe you are looking for something like this:

nc_data<-nc_open("chess-met_precip_gb_1km_daily_20150101-20150131.nc")
lon<-lon<-nc_data$dim$LON$vals
lat<-nc_data$dim$LAT$vals

or

lon<-ncvar_get(nc_data,nc_data$dim$LON)
lat<-ncvar_get(nc_data,nc_data$dim$LAT)

Note that the LON and LAT can be anything as Mike said. Hope it's helps.

Ani

On Wed, Nov 9, 2022 at 7:54 PM 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



More information about the R-sig-Geo mailing list