convert PRS92 zone 3 to latitude and longitude

Hi,

In my previous power BI project, I had a small R code that run run inside power query to convert UTM coordinates to Latitude and Longitude. Now for my new project in the Philippines are not UTM anymore rather the coordinates are PRS92 zone3 Philippines (EPSG 3123) therefore my code project them wrongly. As Rstudio beginner I was not able to modify my code. Maybe someone here can help me out? Below I pasted my code and coordinate samples that need to be converted to Lat, Long decimal degrees.

My code:

library(proj4)
library(tidyverse)
library(tseries)
library(leaflet)

mydata<-dataset

proj4string <- "+proj=PRS92 +zone=3 +north +ellps=EPSG3123 +datum=EPSG3123 +units=m +no_defs "
#xy <- data.frame(x=dataset$cutterPosE, y=dataset$cutterPosN)
pj <- project(data.frame(x=dataset$cutterPosE, y=dataset$cutterPosN), proj4string, inverse=TRUE)

mydata$latcutter<-pj$y
mydata$longcutter<-pj$x


Sample data:

cutterPosE [m] cutterPosN [m]

480848.47 1626260.92
480880.04 1626224.18
480888.28 1626211.29
480836.18 1626272.29
480796.59 1626288.83
480796.32 1626290.92
480833.81 1626276.47
480852.1 1626264.81
480852.48 1626264.42
480852.4 1626264.27
480852.52 1626264.39
480854.54 1626262.38
480877.56 1626234.8
480890.4 1626212.89
480881.72 1626232.5
480847.66 1626269.58
480805.09 1626290.04
480794.27 1626294.21
480826.56 1626284.35
480869.07 1626253.11
480890.82 1626220.83

Hi @proto55,
Welcome to the RStudio Community Forum.

Try this code

suppressPackageStartupMessages(library(proj4))

dataset <- read.table(header=TRUE, text=c("
cutterPosE cutterPosN
480848.47 1626260.92
480880.04 1626224.18
480888.28 1626211.29
480836.18 1626272.29
480796.59 1626288.83
480796.32 1626290.92
480833.81 1626276.47
480852.1 1626264.81
480852.48 1626264.42
480852.4 1626264.27
480852.52 1626264.39
480854.54 1626262.38
480877.56 1626234.8
480890.4 1626212.89
480881.72 1626232.5
480847.66 1626269.58
480805.09 1626290.04
480794.27 1626294.21
480826.56 1626284.35
480869.07 1626253.11
480890.82 1626220.83
"))

mydata <- dataset

# See: https://spatialreference.org/ref/epsg/3123/proj4js/

proj4string <- "+proj=tmerc +lat_0=0 +lon_0=121 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m +no_defs"
xy <- data.frame(x=dataset$cutterPosE, y=dataset$cutterPosN)
pj <- project(data.frame(x=dataset$cutterPosE, y=dataset$cutterPosN), proj4string, inverse=TRUE)

mydata$latcutter<-pj$y
mydata$longcutter<-pj$x

plot(latcutter ~ longcutter, data=mydata)

Created on 2021-09-10 by the reprex package (v2.0.1)

hi @DavoWW,

thanks for your warm welcome.

And yes this morning I found on https://spatialreference.org/ the same as you suggested:

+proj=tmerc +lat_0=0 +lon_0=121 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m +no_defs

and this worked.

KR
Proto

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.