rgeospatialutm

UTM to Lat/Long conversion


I am having trouble to convert coordinates from UTM to lat/long for a known location. If you ask AI to do the calc for you, it gives you the correct answer but for some reason my R "terra" package code is not returning the same result. The expected lat/long outcome of the X (Easting) = 791423.36, Y (Northing) = 6341151.30 in France (Salindres) should be 44.36 and 4.14.

library(terra)
v <- vect( as.matrix( cbind(791423.36, 6341151.30) ), crs = "EPSG:32631")
v
y <- project(v, "EPSG:4326")
y 

the outcome:

class       : SpatVector 
geometry    : points 
elements    : 1
extent      : 791423.4, 791423.4, 6341151, 6341151  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs 

class       : SpatVector 
geometry    : points 
elements    : 1
extent      : 7.815223, 7.815223, 57.12102, 57.12102  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs

Solution

  • Using this page as a resource: https://epsg.io/?q=France%20kind%3APROJCRS.
    Through some trail and error crs=2154 seems to provide the correct answer.

    library(sf)
    
    p1<- st_sfc(st_point(c(791423.36, 6341151.30)), crs=2154)
    st_transform(p1, crs=4326)
    
    
    Geometry set for 1 feature 
    Geometry type: POINT
    Dimension:     XY
    Bounding box:  xmin: 4.143171 ymin: 44.16341 xmax: 4.143171 ymax: 44.16341
    Geodetic CRS:  WGS 84
    POINT (4.143171 44.16341)