Re: [R] about netcdf files

2016-08-02 Thread Marc Girondot via R-help
You can find many tutorials in internet. For example, I did one here: http://max2.ese.u-psud.fr/epc/conservation/Girondot/Publications/Blog_r/Entrees/2014/4/27_Comparison_between_packages_RnetCDF%2C_ncdf4_and_ncdf.html Without any reproducibl example, it is impossible to help you further. Sincere

Re: [R] about netcdf files

2016-08-01 Thread lily li
Thanks, Roy. I will do a search. In addition, how to look at spatial patterns from this netcdf file? Thanks again. On Mon, Aug 1, 2016 at 11:46 AM, Roy Mendelssohn - NOAA Federal < roy.mendelss...@noaa.gov> wrote: > Hi Lily: > > If you download the vignette to my xtractomatic package ( > http://

Re: [R] about netcdf files

2016-08-01 Thread Roy Mendelssohn - NOAA Federal
Hi Lily: If you download the vignette to my xtractomatic package (http://coastwatch.pfeg.noaa.gov/xtracto/index.html) there are any number of examples using ggplot2 to make maps from netcdf data, HTH, -Roy > On Aug 1, 2016, at 10:35 AM, lily li wrote: > > Hi all, > > I can read the data,

Re: [R] about netcdf files

2016-08-01 Thread lily li
Hi all, I can read the data, but how to plot it using ggplot or something? In this case, x-axis should be longitude, and y-axis should be latitude. I tried to plot using raster function, but the x and y axes are from 0 to 1. Thanks again. The code is like this: pre1 = nc_open('sample_precip_daily

Re: [R] about netcdf files

2016-07-27 Thread lily li
Hi Jon, The versions are: raster_2.5-2 sp_1.2-3 On Wed, Jul 27, 2016 at 9:31 AM, Jon Skoien wrote: > Hi Lily, > > You can ignore the first three lines, they are just for information. > Which version of raster do you have? I see that the attempt to read the > crs-variable was not wrapped in a t

Re: [R] about netcdf files

2016-07-27 Thread Jon Skoien
Hi Lily, You can ignore the first three lines, they are just for information. Which version of raster do you have? I see that the attempt to read the crs-variable was not wrapped in a try-call in earlier versions. Upgrading might help. Best, Jon On 7/27/2016 5:13 PM, lily li wrote: > Hi Jon,

Re: [R] about netcdf files

2016-07-27 Thread Jon Skoien
I think you get the error because you passed the object from nc_open(), you should rather pass the filename of the netCDF, so: pre = brick("sample_precip_daily.nc") From the test-file, this gives you a RasterBrick-object with 5*9 pixels and 7305 layers. Then you can extract data.frames of each

Re: [R] about netcdf files

2016-07-26 Thread Roy Mendelssohn - NOAA Federal
Hi Lily: > On Jul 26, 2016, at 2:00 PM, lily li wrote: > > Here are the results. Yes, I tried to read netcdf files, but cannot grasp the > contents. Thanks for helping out. > > > str(pre1) A guide to netcdf files and R can be found at https://www.image.ucar.edu/GSP/Software/Netcdf/, it would

Re: [R] about netcdf files

2016-07-26 Thread lily li
How to read continuous daily precipitation at each grid cell, and then export to a csv file? Later, there should be several csv files, each represents daily precipitation data for one grid cell. Thanks a lot. On Tue, Jul 26, 2016 at 2:52 PM, Roy Mendelssohn - NOAA Federal < roy.mendelss...@noaa.go

Re: [R] about netcdf files

2016-07-26 Thread lily li
Here are the results. Yes, I tried to read netcdf files, but cannot grasp the contents. Thanks for helping out. > str(pre1) List of 14 $ filename : chr "~/Downloads/sample_precip_daily.nc" $ writable : logi FALSE $ id : int 262144 $ safemode : logi FALSE $ format : chr "NC_F

Re: [R] about netcdf files

2016-07-26 Thread Roy Mendelssohn - NOAA Federal
Hi Lily: I doubt the mail-list would pass through the netcdf file. Instead, could you do the following, and post the results: library(ncdf4 pre1 = nc_open('sample_precip_daily.nc') str(pre1) nc_close(pre1) I have a feeling you haven't worked much with netcdf files. I will try to find a tutoria

Re: [R] about netcdf files

2016-07-26 Thread lily li
Thanks for your reply. But it says "Error in (function (classes, fdef, mtable)): unable to find an inherited method for function 'brick' for signature 'ncdf4' " The dataset is attached. It contains daily precipitation data for 20 years, within a rectangle, so that there are several grid points. I

Re: [R] about netcdf files

2016-07-26 Thread Jon Skoien
You could try with the brick function from the raster package. bvar = brick(netcdfName) This uses the ncdf4 functions for opening and reading the netcdf, but makes it easier to extract data for each day: p1 = rasterToPoints(bvar[[1]]) and write p1 to csv. Best, Jon On 7/26/2016 6:54 AM, li

Re: [R] about netcdf files

2016-07-25 Thread David Winsemius
Please show code that allows potential responders to reply meaningfully. -- David > On Jul 25, 2016, at 9:54 PM, lily li wrote: > > Hi all, > > I have a problem in opening netcdf files. If one netcdf file contains > longitude, latitude, and daily precipitation. How to relate each > precipitat

[R] about netcdf files

2016-07-25 Thread lily li
Hi all, I have a problem in opening netcdf files. If one netcdf file contains longitude, latitude, and daily precipitation. How to relate each precipitation record to its associated location, and export them as csv files? Thanks. I just use nc_open(), ncvar_get(), but it is not very helpful. Than