[R-sig-Geo] trouble with spTransform
Roger Bivand
Roger.Bivand at nhh.no
Thu May 17 09:15:26 CEST 2012
On Thu, 17 May 2012, Hodgess, Erin wrote:
> Hello again.
>
> I'm having a little bit of trouble with spTransform (probably I'm doing it wrong), but here is what I'm doing:
>
>
> Original data frame with UTM locations near Phuket, Thailand:
>> test1.df
> Loc east north
> 1 a 748.168 602.861
> 2 b 754.302 615.609
>> proj1 <- CRS("+proj=utm +zone=47N")
Your points are 750m east and 600m north of the given projection origin.
If you meant km, set the units by adding +units=km to the proj4string.
However, this gives me:
coordinates Loc
1 (101.24, 5.44994) a
2 (101.295, 5.56496) b
which is not on Phuket, so something else is wrong here. Do you know
definitely that the input coordinates are UTM zone 47? Reversing the
eastings and northings gets a bit closer:
> proj1 <- CRS("+proj=utm +zone=47N +units=km")
> coordinates(test1.df) <- c("north", "east")
> proj4string(test1.df) <- proj1
> spTransform(test1.df, CRS("+proj=longlat +datum=WGS84"))
coordinates Loc
1 (99.9308, 6.7677) a
2 (100.046, 6.82295) b
but isn't there yet (reversed coordinate order does happen). What was the
source of the coordinates?
Roger
>> coordinates(test1.df) <- c("east","north")
>> proj4string(test1.df) <- proj1
>
> Set up a spatial data frame
>> test1.df
> coordinates Loc
> 1 (748.168, 602.861) a
> 2 (754.302, 615.609) b
>> spTransform(test1.df, CRS("+proj=longlat +datum=WGS84"))
> coordinates Loc
> 1 (94.518, 0.00543748) a
> 2 (94.518, 0.00555246) b
>>
>
> Now the answers should be about 8 degrees north and 98 degrees East.
>
> Any suggestions would be most appreciated.
>
> Sincerely,
> Erin
>
>
> Erin M. Hodgess, PhD
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: hodgesse at uhd.edu
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
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