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

Martin Ivanov martin.ivanov at ifg.uni-tuebingen.de
Thu Aug 16 11:01:47 CEST 2012


Dear Roger,

Thank You very much for Your swift response. I did some testing of the 
rgdal revision.
crds <- matrix(data=c(9.05, 48.52), ncol=2)
spPoint <- SpatialPoints(coords=crds,
  proj4string=CRS(paste("+proj=ob_tran +o_proj=longlat +o_lon_p=-162",
  "+o_lat_p=39.25 +lon_0=180 +ellps=sphere +no_defs")))

spTransform(spPoint, CRS("+proj=longlat +ellps=sphere +no_defs"), 
use_ob_tran=TRUE)
sppdf <- SpatialPointsDataFrame(coords=spPoint, data=data.frame(100), 
proj4string=proj4string(spPoint))
  spTransform(sppdf, CRS("+proj=longlat +ellps=sphere +no_defs"), 
use_ob_tran=TRUE)
sppdf at coords <- crds*pi/180
spTransform(sppdf, CRS("+proj=longlat +ellps=sphere +no_defs"), 
use_ob_tran=TRUE)

1. If you run the code, you will see that the new parameter use_ob_tran 
works for the spatial point, but does not
for the SpatialPointsDataFrame. You still have to multiply the 
coordinates of the data frame by pi/180.
2. Oddly, if you run:
spTransform(spPoint, CRS("+proj=longlat +ellps=sphere +no_defs"), 
use_ob_tran=FALSE)
Error in spTransform(spPoint, CRS("+proj=longlat +ellps=sphere 
+no_defs"),  :
   object 'use_ob_tran' not found

while with the data frame you get no such complaint:
spTransform(sppdf, CRS("+proj=longlat +ellps=sphere +no_defs"), 
use_ob_tran=FALSE)

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