Description Usage Arguments Details Value Warning Author(s) References See Also Examples
Project coordinates based on projection in the first Models3-formatted file to the projection given in the second Models3-formatted file.
1 | project.M3.1.to.M3.2(x, y, from.file, to.file, units, ...)
|
x |
x-coordinates in model units from projection in first file |
y |
y-coordinates in model units from projection in first file |
from.file |
Name of Models3-formatted file with the same
model projection as |
to.file |
Name of Models3-formatted file with the model
projection to which you want |
units |
Units of |
... |
Other arguments to pass to |
This function calls get.proj.info.M3
which reads
the projection information (using the package ncdf4) and
transforms it to strings that are understood by functions in
rgdal. Package rgdal provides the R interface to GDAL
(Geospatial Data Abstraction Library, http://www.gdal.org).
A list containing the elements coords
and units
.
The element coords
contains a matrix of coordinates using
projection in to.file
. The element units
contains
the units of the coordinates, which are the same as those specified
for input x
and y
.
This function assumes the projections in
from.file
and to.file
are Lambert conic conformal or
polar stereographic.
Jenise Swall
project.lonlat.to.M3
, project.M3.to.lonlat
, get.proj.info.M3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## Find the path to a demo file with lambert conic conformal projection.
lcc.file <- system.file("extdata/ozone_lcc.ncf", package="M3")
## Read in the ozone for July 4 for eastern U.S.
lcc.oz <- get.M3.var(file=lcc.file, var="O3",
lcol=90, ucol=130, lrow=30, urow=80,
ldatetime=as.Date("2001-07-04"),
udatetime=as.Date("2001-07-04"))
## Get the cell centers for this subset.
east.ctrs <- expand.grid(lcc.oz$x.cell.ctr, lcc.oz$y.cell.ctr)
plot(east.ctrs, cex=0.3, xlab="x", ylab="y")
## Find map lines on this projection, superplot.
lcc.state.bds <- get.map.lines.M3.proj(file=lcc.file)$coords
lines(lcc.state.bds, col="darkblue")
## Find the path to a demo file with polar stereographic projection.
polar.file <- system.file("extdata/surfinfo_polar.ncf", package="M3")
## Put the cell centers from the subsetted ozone data on this polar
## stereographic projection.
polar.oz <- project.M3.1.to.M3.2(east.ctrs[,1], east.ctrs[,2],
from.file=lcc.file,
to.file=polar.file,
units=lcc.oz$hz.units)
## Plot the cells centers and boundary lines on the polar
## stereographic projection.
dev.new()
plot(polar.oz$coords)
polar.state.bds <- get.map.lines.M3.proj(file=polar.file)$coords
lines(polar.state.bds, col="darkblue")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.