Skip to content

about netcdf files

3 messages · lily li, Roy Mendelssohn - NOAA Federal

#
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.nc')
pre.3d = ncvar_get(pre1, 'precipitation')

require(raster)
rplot = t(pre.3d[, , 1])
r = raster(rplot[nrow(rplot):1, ]
plot(r)
On Tue, Jul 26, 2016 at 1:07 PM, lily li <chocold12 at gmail.com> wrote:

            

  
  
#
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
**********************
"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 address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn at noaa.gov www: http://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.
#
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.mendelssohn at noaa.gov> wrote: