Hi all, I am using Windows 7 and R Studio version 3.0.2 (2013-09-25). I am relatively new to R and am trying to make a contour plot from a 3D data grid. I my data file has the following specifics: [1] "file Data.nc has 3 dimensions:" [1] "time Size: 96" [1] "lat Size: 21" [1] "lon Size: 61" [1] "------------------------" [1] "file Data.nc has 2 variables:" [1] "double U[time,lat,lon] Longname:U Missval:1e+30" [1] "double V[time,lat,lon] Longname:V Missval:1e+30" lat and lon includes latitude and longitude values from a certain region in a 1°grid time includes different months over 8 years I would like to draw 1) a contourplot of the mean U (mean U of all times), at the different locations (x=lon, y=lat) 2) a contourplot of U at the different locations (x=lon, y=lat) at different times. I have only made contourplots with 2D data (i.e. contour (lat,lon, z) and am struggling a bit to find help. Any suggestions are very much appreciated. Cheers, Lydia --><((((º>[[alternative HTML version deleted]]
Well one would expect that you might find something useful by searching the obvious, like ?contourplot and following the links therein. It also seems (to me, anyway) that you have made little effort to understand how R works, its data structures, syntax, and so forth. So please peruse "An Introduction to R" (or one of the many R tutorials on the web) to learn about such basics before posting further if I am correct in this assertion. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." H. Gilbert Welch On Mon, May 12, 2014 at 2:27 PM, Lydia Keppler <lydiakeppler at gmail.com> wrote:> Hi all, > > I am using Windows 7 and R Studio version 3.0.2 (2013-09-25). > I am relatively new to R and am trying to make a contour plot from a 3D > data grid. > > I my data file has the following specifics: > > [1] "file Data.nc has 3 dimensions:" > [1] "time Size: 96" > [1] "lat Size: 21" > [1] "lon Size: 61" > [1] "------------------------" > [1] "file Data.nc has 2 variables:" > [1] "double U[time,lat,lon] Longname:U Missval:1e+30" > [1] "double V[time,lat,lon] Longname:V Missval:1e+30" > > lat and lon includes latitude and longitude values from a certain region in > a 1?grid > time includes different months over 8 years > > I would like to draw > 1) a contourplot of the mean U (mean U of all times), at the different > locations (x=lon, y=lat) > 2) a contourplot of U at the different locations (x=lon, y=lat) at > different times. > > I have only made contourplots with 2D data (i.e. contour (lat,lon, z) and > am struggling a bit to find help. > > Any suggestions are very much appreciated. > Cheers, > > Lydia > > -- >><((((?> > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
Granted, you are new here, but reading the Posting Guide is advice included in every post on this list. One key recommendation found there is to not post in HTML, as we don't see what you see when you do that. Use plain text email. Another key piece of advice in the Posting Guide is to provide a reproducible example. That means enough code that we see the a reasonable subset of the data you are working with in our R environments. I think [1] is a helpful guide to communicating in a reproducible fashion about R questions. It is not clear from your discussion that you have actually imported and worked with your data yet, but you may have to read enough documentation to actually do so before we can make progress on this question. It looks to me like you need to study indexing in "An Introduction to R", because that understanding will allow you to turn your 3D problem into a series of 2D problems. Depending how your data are stored, finding the mean may involve the apply or rowSums functions, or some nested for loops. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On May 12, 2014 2:27:54 PM PDT, Lydia Keppler <lydiakeppler at gmail.com> wrote:>Hi all, > >I am using Windows 7 and R Studio version 3.0.2 (2013-09-25). >I am relatively new to R and am trying to make a contour plot from a 3D >data grid. > >I my data file has the following specifics: > >[1] "file Data.nc has 3 dimensions:" >[1] "time Size: 96" >[1] "lat Size: 21" >[1] "lon Size: 61" >[1] "------------------------" >[1] "file Data.nc has 2 variables:" >[1] "double U[time,lat,lon] Longname:U Missval:1e+30" >[1] "double V[time,lat,lon] Longname:V Missval:1e+30" > >lat and lon includes latitude and longitude values from a certain >region in >a 1??grid >time includes different months over 8 years > >I would like to draw >1) a contourplot of the mean U (mean U of all times), at the different >locations (x=lon, y=lat) >2) a contourplot of U at the different locations (x=lon, y=lat) at >different times. > >I have only made contourplots with 2D data (i.e. contour (lat,lon, z) >and >am struggling a bit to find help. > >Any suggestions are very much appreciated. >Cheers, > >Lydia
Hi Lydia, Your question match more the topics of the r-sig-geo list. Please have a look at the "raster" package, as well as the "rasterVis" package to read and work with NetCDF format. Regards, Pascal On Tue, May 13, 2014 at 6:27 AM, Lydia Keppler <lydiakeppler at gmail.com> wrote:> Hi all, > > I am using Windows 7 and R Studio version 3.0.2 (2013-09-25). > I am relatively new to R and am trying to make a contour plot from a 3D > data grid. > > I my data file has the following specifics: > > [1] "file Data.nc has 3 dimensions:" > [1] "time Size: 96" > [1] "lat Size: 21" > [1] "lon Size: 61" > [1] "------------------------" > [1] "file Data.nc has 2 variables:" > [1] "double U[time,lat,lon] Longname:U Missval:1e+30" > [1] "double V[time,lat,lon] Longname:V Missval:1e+30" > > lat and lon includes latitude and longitude values from a certain region in > a 1?grid > time includes different months over 8 years > > I would like to draw > 1) a contourplot of the mean U (mean U of all times), at the different > locations (x=lon, y=lat) > 2) a contourplot of U at the different locations (x=lon, y=lat) at > different times. > > I have only made contourplots with 2D data (i.e. contour (lat,lon, z) and > am struggling a bit to find help. > > Any suggestions are very much appreciated. > Cheers, > > Lydia > > -- >><((((?> > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan