[R-sig-Geo] Coordinate transformation for directions?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu May 17 10:55:03 CEST 2012


spTransform does a great job of transforming points from one CRS to
another, but what's the best way of transforming directions?

For example, the wind at a point is blowing from the SW in lat-long
coordinates. That would be -3pi/4 radians if you consider lat-long as
a cartesian coordinate system. But suppose you want to work in
Ordnance Survey grid references. These coords are rotated slightly
compared to epsg:4326, and the rotation is different at different
points. Lat-long North is never exactly straight up on OSGrid maps.

 My thinking is to consider a small vector (how small?) from (x,y) to
(x+dx,y+dy) in the required direction in lat-long, then transform
those two points to OSGrid, then compute the angle with the atan2
function.

 Apart from wondering how small the vector needs to be, have I missed
any other subtleties? Has anyone written this already?

 Note these are point-wise directions, not bearings of A from B. Great
circles are not involved!

Barry



More information about the R-sig-Geo mailing list