[R-sig-Geo] Coordinate/grid for ncdf data
Michael Sumner
mdsumner at utas.edu.au
Thu Aug 9 01:48:43 CEST 2007
Hi, can you provide an example file?
I'd recommend avoiding NetCDF for various reasons, why don't you simply add
each value column from the separate files to a new column in a
SpatialGridDataFrame?
That would be the recommend sp way to proceed here. If you really need to
create a NetCDF file, please let us know more about your OS and the
package/s and versions you are using (ncdf I presume?) - however such
questions should include the ncdf(?) package author at least.
Cheers, Mike.
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Thomas Szegvary
Sent: Wednesday, 8 August 2007 11:13 PM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] Coordinate/grid for ncdf data
Hi!
I have a table with 3 columns, 2 for long/lat coordinates and 1 for values
(radon concentration). I have data for every week of the year
2006,distributed in 52 tables/files. I want to create a NetCDF file, which
is much easier to handle than extracting the values from 52 tables. I tried
the following for the first dataset (i.e first week):
#extracting coordinates and values from my tables (which have also other
information I don't need)
W01<-read.table("RN_weekly/KW01_RN.dat")
long<-W01$V1
lat<-W01$V2
RN01<-W01$V3
#defining dimensions for coordinates
dim1 <- dim.def.ncdf( "EW","degrees", as.double(long))
dim2 <- dim.def.ncdf( "SN","degrees", as.double(lat))
#defining variable for my values I want to have the time series varz <-
var.def.ncdf("Radon","Bq/m2/h1", list(dim1,dim2), -1,
longname="Radon flux rate")
#creating the netcdf file and filling the variable varz with the first
data-week from my time series nc.rn <- create.ncdf("rn_weekly.nc",varz)
put.var.ncdf(nc.rn,varz,RN01)
close.ncdf(nc.rn)
The problem now is that the last step (put.var.ncdf) doesn't work, because
it says I am trying to "error: you asked to write 111788329 values, but the
passed data array only has 10573* entries!". So I think the problem is that
I need an array with two dimensions (coordinates...) for my values. But how
do I get this from my tables??
*10573 are the pixels for my area
Thanks for any help!
Thomas
__
Thomas Szegvary
Institute of Environmental Geosciences
Department of Geosciences
University of Basel
Bernoullistrasse 30
CH - 4056 Basel
Tel. 41-61-267 04 82
Fax. 41-61-267 04 79
Email: t.szegvary at unibas.ch
www.radon.unibas.ch
www.unibas.ch/environment
_______________________________________________
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