简体   繁体   中英

How to convert UTM coordinates to lat and long in R special case Africa

Hello I tried this code from here How to convert UTM coordinates to lat and long in R like this

   SP <- SpatialPoints(cbind(457500, 9347500))
   sputm <- SpatialPoints(SP, proj4string=CRS("+proj=utm +zone=35M +datum=WGS84")) 
   spgeo <- spTransform(sputm, CRS("+proj=longlat +datum=WGS84"))

with this result

   spgeo
   #SpatialPoints:
   #     coords.x1 coords.x2
   #[1,]  23.25527  84.16145
   #Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs 

But this is wrong. the result should be lat=-5.90303 long=26.616044

what is wrong in this code that the result is so different Thank you for any help.

You have to use +zone=35 +south instead of +zone=35M .

library(rgdal)
SP <- SpatialPoints(cbind(457500, 9347500))
sputm <- SpatialPoints(SP, proj4string=CRS("+proj=utm +zone=35 +south +datum=WGS84"))
spTransform(sputm, CRS("+proj=longlat +datum=WGS84"))
#SpatialPoints:
#     coords.x1 coords.x2
#[1,]  26.61604  -5.90303
#Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84
#+ellps=WGS84 +towgs84=0,0,0 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM