rgisgeospatialrgdal

Plotting UTM / Coordinates


I am new to R programming, I have a csv/excel file of 20 towns in a country which contains the in the below format,

Towns UTM Cordinates UTM Cordinaetes
xxxxxxxx 1377777 249514
yyyyyyyy 142145 228942

I am unable to plot them into a map, Does anyone have any idea of how t plot these UTM Cordinates. Is it possible to plot towns in R programming with UTM? If so can anyone help me out here. I have the shape file for the country with me as well. But I am not sure how to process.

myfilepath <- file.choose()
Cordinates<-read.csv(myfilepath,header=TRUE)
Cordinates
str(Cordinates)
library(rgdal)
library(sp)
library(data.table)
library(ggplot2)
library(tibble)
myfilepath <- file.choose()
Shapefile<-readOGR(myfilepath)
plot(Shapefile)
ggmap(Shapefile)+geom_point(aes(x=Easting,y=Northing,col=Cordinates))

Any help would be appreciated.


Solution

  • The trick is to determine the grid system used. After much searching, the code for standard Republic of Ireland grid is epsg:29902

    The first step is to transform the Irish grid coordinates into standard latitude and longitude. This is accomplished with the "rgdal" library.

    library(rgdal)    
    
    points <- read.table(header=TRUE, text = "Towns Easting Northing 
                          Belclare 137777 249514
                          Carnmore 142145 228942")
    
    #Pull out the location columns and rename
    point <- points[,2:3]
    names(point) <-c('x', 'y')
    
    #convert to corrdinates and define initial coordinates systems
    coordinates(point) <- c('x', 'y')
    proj4string(point)=CRS("+init=epsg:29902")  #29903 is the grid for Ireland
    
    #Transform the Ireland's grid to longitude & latitude
    coord<-spTransform(point,CRS("+init=epsg:4326"))
    coord
    

    This will transform your list of coordinates, please search this site on how to plot to a map. There are many options available.