0

I have the following data:

EASTING NORTHING
1   535234  7528392
2   538091  7533652
3   540850  7549211
4   543208  7561915
5   552494  7579475
6   553310  7571159

I want to transform it from UTM coordinates to Latitude and Longitude, and store them in a dataframe.

user438383
  • 5,716
  • 8
  • 28
  • 43

2 Answers2

2

Expanding on Grzegorz Sapijaszko answer. As he points out, there are 60 UTM zones. They are 6 degrees wide, and the zone your data are in can be estimated like this for a longitude:

lon <- 5
ceiling((lon + 180) / 6)
#[1] 31

If that is your zone (have a look here, it is a bit more complex than the formula above), your coordinate reference system would be "+proj=utm +zone=31", and you can set that to your data (here with terra)

library(terra)
crs <- "+proj=utm +zone=31"
p1 <- vect(df, geom=c("EASTING", "NORTHING"), crs=crs)
p1
# class       : SpatVector 
# geometry    : points 
# dimensions  : 6, 0  (geometries, attributes)
# extent      : 535234, 553310, 7528392, 7579475  (xmin, xmax, ymin, ymax)
# coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs 

And then project to lon/lat and plot on top of data you have for the area to see if it correct

p2 <- project(p1, "+proj=longlat")
#plot(x)
#points(p2)
Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63
1

What you have to know about your data, is current coordinate system. Please note, that there is 60 UTM zones. There is a plenty other systems, which are metric (your data suggests metric system).

Ad rem: to convert from one to another you can use several ways. You can use terra, rgdal, sf packages. Please note, I have chosen EPSG:3857 for your data, which can be incorrect.

Lines <- 
"EASTING NORTHING
535234 7528392
538091 7533652
540850 7549211
543208 7561915
552494 7579475
553310 7571159"

df <- read.csv(textConnection(Lines), as.is = TRUE, header = TRUE, sep = " ")

library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.2, PROJ 7.2.1; sf_use_s2() is TRUE
p1 <- st_as_sf(df, coords = c("EASTING", "NORTHING"), crs = "EPSG:3857")
p2 <- st_transform(p1, crs= "EPSG:4326")
p2
#> Simple feature collection with 6 features and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 4.808089 ymin: 55.84889 xmax: 4.970468 ymax: 56.10564
#> Geodetic CRS:  WGS 84
#>                    geometry
#> 1 POINT (4.808089 55.84889)
#> 2  POINT (4.833754 55.8754)
#> 3 POINT (4.858538 55.95373)
#> 4  POINT (4.87972 56.01757)
#> 5 POINT (4.963138 56.10564)
#> 6 POINT (4.970468 56.06396)

Created on 2022-01-24 by the reprex package (v2.0.1)

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63
Grzegorz Sapijaszko
  • 1,913
  • 1
  • 5
  • 12