|
|||||||||||||||||||||
DetailsIf the user wants to subset the variable by row, column, layer, or time step number, this can be accomplished easily using standard R methods for subsetting the array of variable values. This function was written to help the user who does not know the row, column, or time step numbers, but who wants to subset according to human-readable dates and times or according to projection units. ValueSubsetted array of variable values. (The array's format is preserved.) Author(s)Jenise Swall Referenceshttp://www.baronams.com/products/ioapi/VBLE.html, See Also
Examples## Find the path to the demo file. polar.file <- system.file("extdata/surfinfo_polar.ncf", package="M3") ## Read in the terrain elevation variable. elev <- get.M3.var(file=polar.file, var="HT") ## Make a plot. image(elev$x.cell.ctr, elev$y.cell.ctr, elev$data[,,1], xlab="Projection x-coord (km)", ylab="Projection y-coord (km)", zlim=range(elev$data[,,1]), col=heat.colors(15)) ## Subset to a smaller geographic area in southwestern U.S. subset.elev <- var.subset(elev, llx=-2000, urx=0, lly=-6500, ury=-4000) ## Make a plot of this subset. image(subset.elev$x.cell.ctr, subset.elev$y.cell.ctr, subset.elev$data[,,1], xlab="Projection x-coord (km)", ylab="Projection y-coord (km)", zlim=range(subset.elev$data[,,1]), col=heat.colors(15)) ## Superimpose U.S. state boundaries on the plot. state.bds <- get.map.lines.M3.proj(file=polar.file)$coords lines(state.bds) ResultsR version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(M3) Loading required package: ncdf4 Loading required package: rgdal Loading required package: sp rgdal: version: 1.1-10, (SVN revision 622) Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 1.11.3, released 2015/09/16 Path to GDAL shared files: /usr/share/gdal/1.11 Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492] Path to PROJ.4 shared files: (autodetected) Linking to sp version: 1.2-3 Loading required package: maps # maps v3.1: updated 'world': all lakes moved to separate new # # 'lakes' database. Type '?world' or 'news(package="maps")'. # Loading required package: mapdata > png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/M3/var.subset.Rd_%03d_medium.png", width=480, height=480) > ### Name: var.subset > ### Title: Subset the array resulting from a call to 'get.M3.var'. > ### Aliases: var.subset > > ### ** Examples > > ## Find the path to the demo file. > polar.file <- system.file("extdata/surfinfo_polar.ncf", package="M3") > > ## Read in the terrain elevation variable. > elev <- get.M3.var(file=polar.file, var="HT") Time independent file - reading only time step available. > ## Make a plot. > image(elev$x.cell.ctr, elev$y.cell.ctr, elev$data[,,1], + xlab="Projection x-coord (km)", ylab="Projection y-coord (km)", + zlim=range(elev$data[,,1]), col=heat.colors(15)) > > ## Subset to a smaller geographic area in southwestern U.S. > subset.elev <- var.subset(elev, llx=-2000, urx=0, lly=-6500, ury=-4000) > ## Make a plot of this subset. > image(subset.elev$x.cell.ctr, subset.elev$y.cell.ctr, + subset.elev$data[,,1], xlab="Projection x-coord (km)", + ylab="Projection y-coord (km)", zlim=range(subset.elev$data[,,1]), + col=heat.colors(15)) > > ## Superimpose U.S. state boundaries on the plot. > state.bds <- get.map.lines.M3.proj(file=polar.file)$coords > lines(state.bds) > > > > > > dev.off() null device 1 > |
|||||||||||||||||||||
|