lonlat2xy {spectralGP} | R Documentation |
Projects lon/lat coordinates to x/y Euclidean coordinate system
Description
The projection calculates, for all points, the great circle distance in the x direction to the mean longitude and in the y direction to the mean latitude, and uses these distances as the x-y coordinates of the location. This function is copied from the fields library.
Usage
lonlat2xy(lnlt,miles=FALSE)
Arguments
lnlt |
A two-column matrix-like object of lon/lat coordinates to be projected, with longitude in the first column. |
miles |
Indicator of whether distances should be calculated in miles or kilometers (FALSE, the default). |
Details
Note that this is an ad hoc projection best used only for small portions of the globe.
Value
A two-column matrix of projected x/y coordinates, with the x-coordinate in the first column.
Author(s)
copied from the fields library by Christopher Paciorek paciorek@alumni.cmu.edu
See Also
Examples
library(spectralGP)
gp1=gp(c(128,128),matern.specdens,c(1,4))
n=100
locs=cbind(runif(n,20,80),runif(n,40,50))
locs.predict=cbind(runif(n,30,90),runif(n,38,48))
locs=lonlat2xy(locs)
locs.predict=lonlat2xy(locs.predict)
scaled.locs=xy2unit(locs,rbind(locs,locs.predict))
scaled.locs.predict=xy2unit(locs.predict,rbind(locs,locs.predict))
train.map=new.mapping(gp1,scaled.locs)
predict.map=new.mapping(gp1,scaled.locs.predict)
plot(locs,xlim=c(min(locs[,1],locs.predict[,1]),max(locs[,1],
locs.predict[,1])),ylim=c(min(locs[,2],locs.predict[,2]),
max(locs[,2],locs.predict[,2])))
points(locs.predict,col=2)
plot(scaled.locs,xlim=c(0,1),ylim=c(0,1))
points(scaled.locs.predict,col=2)
[Package spectralGP version 1.3.3 Index]