lonlat2xy: Projects lon/lat coordinates to x/y Euclidean coordinate...

Description Usage Arguments Details Value Author(s) See Also Examples

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

1
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

xy2unit, new.mapping

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)

spectralGP documentation built on May 2, 2019, 2:40 a.m.