[R-sig-Geo] rgdal project; inverse does not return original values
Robert Hijmans
r.hijmans at gmail.com
Tue May 19 04:29:20 CEST 2009
I am confused about this behavior of rgdal
> require(rgdal)
> # make a matrix of coordinates
> xygeo <- rbind(c(-180, 0), c(180,0), c(0,0), c(0,20), c(0,90))
> # project to sinusoidial
> xysin <- project(xygeo, "+proj=sinu", inv=FALSE)
> # project back to longlat
> xyinv <- project(xysin, "+proj=longlat", inv=TRUE)
> xygeo
[,1] [,2]
[1,] -180 0
[2,] 180 0
[3,] 0 0
[4,] 0 20
[5,] 0 90
> xyinv
[,1] [,2]
[1,] 180 0
[2,] -180 0
[3,] 0 0
[4,] 0 126759249
[5,] 0 573070423
>
Why are rows 4 and 5 different?
An illustration of the same problem, using 'raster'
> library(raster)
> r <- raster(nrow=36, ncol=18, projs= "+proj=longlat")
> xy <- xyFromCell(r,1:ncell(r))
> par(mfrow=c(1, 3))
> plot(xy) # ok
> xysin <- project(xy, "+proj=sinu", inv=FALSE)
> plot(xysin) # nice
> xyinv <- project(xysin, "+proj=longlat", inv=TRUE)
> plot(xyinv) # ???
Robert
> sessionInfo()
R version 2.9.0 (2009-04-17)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.6-8 sp_0.9-34
loaded via a namespace (and not attached):
[1] grid_2.9.0 lattice_0.17-22
>
More information about the R-sig-Geo
mailing list