1

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.

  • https://stackoverflow.com/questions/30018098/how-to-convert-utm-coordinates-to-lat-and-long-in-r/67463722#67463722 – Peter O. May 10 '21 at 17:44

1 Answers1

3

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 
GKi
  • 37,245
  • 2
  • 26
  • 48