[R-sig-Geo] Different result from sptransform() and ptransform()

Rainer Hurling rhurlin at gwdg.de
Sat Jan 28 19:55:40 CET 2012


On 28.01.2012 19:30 (UTC+1), Agustin Lobo wrote:
> Hi!
> I'm reprojecting and get different results from sptransform() than
> from ptransform():
> (objec cents in https://sites.google.com/site/filestemp2/home/cents.rda)
>
>> str(cents,max.level=2)
> Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
>    ..@ data       :'data.frame':	234 obs. of  4 variables:
>    ..@ coords.nrs : num(0)
>    ..@ coords     : num [1:234, 1:2] 3603500 3604500 3605500 3606500 3607500 ...
>    .. ..- attr(*, "dimnames")=List of 2
>    ..@ bbox       : num [1:2, 1:2] 3603500 2155500 3620500 2167500
>    .. ..- attr(*, "dimnames")=List of 2
>    ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
>
>> proj4string(cents)
> [1] " +init=epsg:3035 +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000
> +y_0=3210000 +ellps=GRS80 +units=m +no_defs"
>> centslonlat<- spTransform(cents,CRS("+init=epsg:4326"))
>> coordinates(centslonlat)[1:3,]
>              X        Y
> [1,] 1.315311 42.23956
> [2,] 1.327326 42.24060
> [3,] 1.339342 42.24163
>
>> a<- ptransform(data = as.data.frame(coordinates(grid1km)), src.proj = CRSargs(CRS("+init=epsg:3035")), dst.proj = CRSargs(CRS("+init=epsg:4326")))

Hmm, grid1km is not known here until now?

Greetings,
Rainer

>> coordinates(a)[1:3,]
>                x         y z
> [1,] 0.02295650 0.7372194 0
> [2,] 0.02316621 0.7372375 0
> [3,] 0.02337593 0.7372556 0
>
> The correct results are those from sptransform(), but I would like to
> know what I'm doing wrong with ptansform()
>
> Thanks
>
> Agus



More information about the R-sig-Geo mailing list