I am trying (and failing) to convert the coordinates in a spatial object (Spatialpolygonsdataframe) form easting/northing to latitude/longitude. The zone is 35S.

I know it can be achieved with spTransform, but I am struggling with it:

sp2 <- spTransform(sp, CRS("+proj=utm +zone=35 +ellps=WGS84 +datum=WGS84 +units=m + no_defs"))


Object of class SpatialPolygonsDataFrame
        min        max
x   68947.1   77921.63
y 9618287.1 9630115.64
Is projected: TRUE 
proj4string :
[+proj=utm +zone=35 +south +datum=WGS84
+units=m +no_defs]
  • how does it not work? error messages? what is sp object and what coordinate system does it have? does it have one at all? Your code looks like it is transforming sp to zone 35, not to lat-long.
    – Spacedman
    Commented Jun 3, 2022 at 15:56
  • many thanks, Spacedman -- the sp object is a SpatialPolygonsDataFrame and the CRS is WGS 84 / UTM Zone 35S. that is as far as I got with assigning the CHRS. yes, I am trying to figure out how to use spTransform to change the coordinates to lat/long. I'm not saying that command above did what I wanted it to :) sorry that was not clear. i feel like I'm missing something obvious.
    – rratnaya
    Commented Jun 3, 2022 at 15:59
  • You assign the CRS to an sp object using proj4string(d)=CRS("+init=epsg:4326") (eg if your data is in epsg 4326 lat-long. That doesn't change the numbers, it only changes the metadata of the CRS. Then spTransform returns a new object with new numbers given by the CRS argument to it. Can you edit your question and show us summary(sp) so we can see if it already has a CRS?
    – Spacedman
    Commented Jun 3, 2022 at 16:09
  • Metadata -- I see. It already has a CRS (I believe) -- as above.
    – rratnaya
    Commented Jun 3, 2022 at 16:16
  • Now we can see it seems to have the right CRS already, so you need to use spTransform to convert to the desired one. See answer.
    – Spacedman
    Commented Jun 3, 2022 at 16:35

1 Answer 1


Given an object sp with the correct CRS assigned to it, then:

sp2 = spTransform(sp, CRS("+init=epsg:4326"))

should create a new object in lat-long coordinates given by the WGS84 "GPS" coordinate system.

  • Thank you -- that works! Found it interesting that I don't have to enter +proj=longlat as well.
    – rratnaya
    Commented Jun 3, 2022 at 18:01
  • The EPSG codes are shortcuts for the expanded definitions - EPSG:4326 is "+proj=longlat +datum=WGS84 +no_defs". You can look these up at epsg.io and other sites. That also gives the fuller WKT string definition which is even more verbose!
    – Spacedman
    Commented Jun 3, 2022 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.