| geodXy {oce} | R Documentation |
The method employs geodesic calculations of the distances along geodesic
curves, i.e. akin to great-circle curves that go along the surface of the
ellipsoidal earth; see geodDist. The results are minimally
sensitive to the ellipsoidal geometry assumed, but this is not a matter in
serious question today. Note that the results are quite unlike the values
returned from a map projection; in the latter case, the results vary greatly
across a range of popular projections. Use the present function for things
like gridding data or calculating drifter speeds.
geodXy(longitude, latitude, longitudeRef = 0, latitudeRef = 0, rotate = 0)
longitude |
vector of longitudes |
latitude |
vector of latitudes |
longitudeRef |
numeric, reference longitude |
latitudeRef |
numeric, reference latitude |
rotate |
numeric, counterclockwise angle, in degrees, by which to
rotate the ( |
Consider the i-th point in the longitude and latitude
vectors. The value of x[i] is inferred from the distance along a
geodesic curve from from (longitude[i], latitude[i]) to
(longitudeRef[i], latitude[i]), i.e. the distance along a line
of constant latitude. Similarly, y[i] is inferred the geodesic
distance from (longitude[i], latitude[i]) to
(longitude[i], latitudeRef). Once the distances are inferred,
signs are calculated from determining the sign of
longitude[i]-longitudeRef for x[i] and similarly y[i].
Data frame of x and y, geodesic distance components,
measured in metres. See “Details” for the definitions.
Until 2015-11-02, the names of the arguments
were lon, lat, lon.ref and lat.ref; these were
changed to be more in keeping with names in the rest of oce.
The calculation is devised by the author and is without known precedent in the literature, so users might have to explain it in their publications–hence the detailed discussion below.
This is possibly useful, possibly not. The method changed in Oct, 2015.
Dan Kelley
Other functions relating to geodesy: geodDist,
geodGc, geodXyInverse
library(oce)
data(section)
lon <- section[["longitude", "byStation"]]
lat<- section[["latitude", "byStation"]]
lon <- lon
lat <- lat
lonR <- lon[1]
latR <- lat[1]
## 1. ellipse
km <- 1e3 # nicer for graphs
xy <- geodXy(lon, lat, lonR, latR) / km
## 2. sphere, with scale tailored to mean local latitude
kmperdeg <- geodDist(0, mean(lat)-0.5, 0, mean(lat)+0.5) # mid-latitude estimate
X <- (lon - lonR) * kmperdeg * cos(lat * pi / 180)
Y <- (lat - latR) * kmperdeg
XY <- list(x=X, y=Y)
## plot, with labels for sphere-ellipse deviations
par(mfrow=c(2,1), mar=c(3, 3, 1, 1), mgp=c(2, 0.7, 0))
plot(lon, lat, asp=1/cos(median(lat*pi/180)))
plot(xy$x, xy$y, asp=1, xlab="x [km]", ylab="y [km]")
rms<- function(x) sqrt(mean(x^2))
mtext(sprintf("RMS dev.: x %.2f km, y %.2f km",
rms(xy$x-XY$x), rms(xy$y-XY$y)), side=3, line=-1)
mtext(sprintf("RMS dev / span: x %.2g, y %.2g",
rms(xy$x-XY$x)/diff(range(xy$x)),
rms(xy$y-XY$y)/diff(range(xy$y))),
side=3, line=-2)