微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

绘制 UTM/坐标

如何解决绘制 UTM/坐标

我是 R 编程的新手,我有一个国家/地区 20 个城镇的 csv/excel 文件,其中包含以下格式,

城镇 UTM 坐标 UTM 坐标
xxxxxxxx 1377777 249514
yyyyyyyy 142145 228942

我无法将它们绘制成地图,有没有人知道如何绘制这些 UTM 坐标。 是否可以使用 UTM 在 R 编程中绘制城镇?如果是这样,任何人都可以在这里帮助我。 我也有这个国家的形状文件。但我不确定如何处理。

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))

任何帮助将不胜感激。

解决方法

这是一个sf-解决方案,利用@Dave2e 的所有辛勤工作来找到所用的正确坐标系...

#convert to simple feature
library( sf )
mysf <- sf::st_as_sf( mydata,coords = c("Easting","Northing"),crs = 29902)

#plot for visual inspection
mapview::mapview(mysf)

enter image description here

,

诀窍是确定使用的网格系统。经过多次搜索,标准爱尔兰共和国网格的代码是 epsg:29902

第一步是将爱尔兰网格坐标转换为标准纬度和经度。这是通过“rgdal”库完成的。

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

这将转换您的坐标列表,请搜索此站点以了解如何绘制到地图。有很多选择。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。