[R-sig-Geo] spTransform: unable to convert coordinates
Roger Bivand
Roger.Bivand at nhh.no
Thu Aug 16 12:06:25 CEST 2012
On Thu, 16 Aug 2012, Martin Ivanov wrote:
> 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)
Thanks, very helpful report - I had missed passing through the arguments
for the Spatial*DataFrame methods. In addition, when use_ob_tran was given
but FALSE, the internal copy wasn't created - it is now in revision 353.
Best wishes,
Roger
>
> Best regards,
>
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list