R: Get the grid coordinates for the grid rows or columns.
get.coord.for.dimension
R Documentation
Get the grid coordinates for the grid rows or columns.
Description
For either the rows or the columns, return the coordinates
of the centers or the edges of the grid cells.
Usage
get.coord.for.dimension(file, dimension, position = "ctr", units)
Arguments
file
Name of Models3-formatted file of interest.
dimension
If “column”/“col”, will obtain
coordinates for columns; if “row” will obtain coordinates
for rows.
position
Choose whether to obtain coordinates of cell edges or
centers for either grid rows or columns. If “ctr” (default),
get the cell center. If “lower”, get bottom or left cell
edge. If “upper”, get top or right cell edge.
units
Units for coordinates of grid rows or columns. Must be
one of “m”, “km”, or “deg”. If
unspecified, the default is “deg” if the file has a
longitude/latitude grid, and “km” otherwise.
Value
A list containing two elements, coords and
units. If dimension is “row”, return as element
coords a vector containing the y-coordinates of the centers
(“ctr”), left (“lower”), or right (“upper”) edges
of each row, depending on the value of argument position. If
dimension is “column” or “col”, return as element
coords a vector containing the x-coordinates of the centers
(“ctr”), left (“lower”), or right (“upper”) edges
of each row, depending on the value of argument position. In
both cases, return as element units the units of the
coordinates (can be “km”, “m”, or “deg”).
Note
Usually, the user will not call this function directly; instead,
it will be called by other functions such as
get.matrix.all.grid.cell.ctrs and
get.M3.var.
## As mentioned in notes above, user will not typically call
## this function directly.
## Find the path to a demo file with lambert conic conformal projection.
lcc.file <- system.file("extdata/ozone_lcc.ncf", package="M3")
## Get a list of the x-coordinates of the centers of the cells.
x.ctrs <- get.coord.for.dimension(lcc.file, dimension="col", units="km")
Results
R 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/get.coord.for.dimension.Rd_%03d_medium.png", width=480, height=480)
> ### Name: get.coord.for.dimension
> ### Title: Get the grid coordinates for the grid rows or columns.
> ### Aliases: get.coord.for.dimension
>
> ### ** Examples
>
> ## As mentioned in notes above, user will not typically call
> ## this function directly.
>
> ## Find the path to a demo file with lambert conic conformal projection.
> lcc.file <- system.file("extdata/ozone_lcc.ncf", package="M3")
>
> ## Get a list of the x-coordinates of the centers of the cells.
> x.ctrs <- get.coord.for.dimension(lcc.file, dimension="col", units="km")
>
>
>
>
>
> dev.off()
null device
1
>