[R-sig-Geo] spTransform: unable to convert coordinates

Martin Ivanov martin.ivanov at ifg.uni-tuebingen.de
Wed Aug 15 13:32:26 CEST 2012

Dear R users,
I have a rotated latitude-longitude grid with coordinates of the north 
pole POLE_LAT=39.25 and POLE_LON=-162 on a sphere with radius 6371 km. 
My data are on a conventional longlat grid on the same sphere. I found 
that I can transform my data to the rotated grid by means of proj4's 
ptransform. For example:
crds <- matrix(data=c(9.05, 48.52), ncol=2); # a pair of geographical 

rot_crds <- 180/pi*ptransform(data=crds*pi/180, dst.proj="+proj=longlat 
+ellps=sphere +no_defs",
  src.proj="+proj=ob_tran +o_proj=longlat +o_lon_p=-162 +o_lat_p=39.25 
+lon_0=180 +ellps=sphere +no_defs")[1:2]
 > rot_crds
[1] -5.917698 -1.871950 # these are the correct coordinates in the 
rotated grid
You may notice that to get the correct result I have to swap the source 
and destination CRS.

I would be happy if I could reproduce that result with the sp function 
spTransform, but I have no luck:
spPoint <- SpatialPoints(coords=crds, proj4string=CRS("+proj=longlat 
+ellps=sphere +no_defs"));
try1 <- spTransform(spPoint, CRS("+proj=ob_tran +o_proj=longlat 
+o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere +no_defs"));
 > try1
      coords.x1 coords.x2
[1,]  2.896087   1.37327# this result is not correct

  I also tried with swappped source and destination:

 > spPoint <- SpatialPoints(coords=crds, proj4string=CRS("+proj=ob_tran 
+o_proj=longlat +o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere 
+ try2 <- spTransform(spPoint, CRS("+proj=longlat +ellps=sphere +no_defs"));
+ try2
      coords.x1 coords.x2
[1,] -170.7407 -46.63283 # this is also incorrect

My question is, is it possible to use spTransform for the kind of 
coordinate conversion I need? Or do I have to stick to
ptransform of proj4?

Best regards,

Dr. Martin Ivanov
Eberhard-Karls-Universität Tübingen
Mathematisch-Naturwissenschaftliche Fakultät
Fachbereich Geowissenschaften
Water & Earth System Science (WESS)
Hölderlinstraße 12, 72074 Tübingen, Deutschland
Tel. +4970712974213

More information about the R-sig-Geo mailing list