[R] Writing .nc files

R. Mark Sharp rm@h@rp @end|ng |rom me@com
Tue Aug 28 20:00:43 CEST 2018


Marco,

Always post to the r-help list to have a better chance of finding someone that can help.

There is a very nice tutorial that you should have found. See http://geog.uoregon.edu/bartlein/courses/geog490/week04-netCDF.html#create-and-write-a-netcdf-file

Mark
R. Mark Sharp, Ph.D.
Data Scientist and Biomedical Statistical Consultant
7526 Meadow Green St.
San Antonio, TX 78251
mobile: 210-218-2868
rmsharp using me.com











> On Aug 28, 2018, at 8:26 AM, R. Mark Sharp <rmsharp using me.com> wrote:
> 
> Marco,
> 
> You will need to ask the list. I have never worked with .nc files.
> 
> Most are wanting to go the other direction .nc to .csv or dataframe. Google search with “.nc file in r”.
> 
> R. Mark Sharp, Ph.D.
> Data Scientist and Biomedical Statistical Consultant
> 7526 Meadow Green St.
> San Antonio, TX 78251
> mobile: 210-218-2868
> rmsharp using me.com
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>> On Aug 27, 2018, at 10:12 AM, Marco Antonio Pérez <marko.luna13 using gmail.com> wrote:
>> 
>> Hello Mark:
>> 
>> I appreciate your sopport in this subject. But now, I need your help again, please. 
>> I wondering if you know how to transform a .csv file to .nc file_
>> 
>> Thanks a lot!!
>> 
>> 2018-08-10 17:08 GMT-03:00 R. Mark Sharp <rmsharp using me.com>:
>> Marco,
>> 
>> The error message indicates that nlon*nlat is 420 and that 1378620/420 has a remainder. For the matrix to form, all rows have to be complete. 
>> 
>> I am guessing you have at least one value incorrect among nlon, nlat, t or the length of fulldatav.
>> 
>> Mark
>> R. Mark Sharp, Ph.D.
>> Data Scientist and Biomedical Statistical Consultant
>> 7526 Meadow Green St.
>> San Antonio, TX 78251
>> mobile: 210-218-2868
>> rmsharp using me.com
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Aug 10, 2018, at 10:00 AM, Marco Antonio Pérez <marko.luna13 using gmail.com> wrote:
>>> 
>>> I am trying to write a function to make a matrix of precipitation with
>>> this secuencie;
>>> ######## PRIMER PERIODO
>>> cordex1 <-
>>> nc_open("pr_CAM-44i_ICHEC-EC-EARTH_rcp45_r12i1p1_SMHI-RCA4_v1_mon_200601-201012.nc")
>>> fullmon1<-ncvar_get(cordex1,"pr")
>>> lat<-ncvar_get(cordex1,"lat", start=c(35.5),count=c(20))
>>> lon <-ncvar_get(cordex1,"lon", start=c(125),count=c(21.5))
>>> t <- ncvar_get(cordex1,"time")
>>> nlon <- dim(lon)
>>> nlat <- dim(lat)
>>> nt <- dim(t)
>>> fulldatav <- as.vector(fullmon1)
>>> fulldata <- matrix(fulldatav, nrow=nlon*nlat, ncol=nt)
>>> lonlat <- expand.grid(lon,lat)
>>> df_cordex1<- data.frame(lonlat,fulldata)
>>> 
>>> but with the expresion  fulldata <- matrix(fulldatav, nrow=nlon*nlat,
>>> ncol=nt) this error appears
>>> Warning message:
>>> In matrix(fulldatav, nrow = nlon * nlat, ncol = nt) :
>>> data length [1378620] is not a sub-multiple or multiple of the number of
>>> rows [420]
>>> 
>>> Somebody help me!!!
>>> 
>>>      [[alternative HTML version deleted]]
>>> 
>>> ______________________________________________
>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> 
> 




More information about the R-help mailing list