[英]Plotting data points on a map in R with unknown latitude and longitude format
我没有使用地图的经验,但是我尝试使用数据集中包含的纬度和经度列来绘制采样图。
到目前为止,我一直关注并尝试过此操作,但没有成功。
> head(test,15)
Country LATITUDE LONGITUDE
3 Austria 474600 161900
4 Finland 693400 285300
5 Italy 415000 133500
6 Switzerland 470300 84200
9 Estonia 593300 260200
10 Slovenia 462200 135600
11 Bulgaria 424600 234500
13 Austria 480600 125200
14 Finland 615200 241200
27 Finland 615100 241800
28 Belgium 510400 30200
29 Switzerland 474100 83200
32 Slovenia 462900 163100
35 Poland 543300 181600
38 Austria 472900 132500
library(rworldmap)
newmap <- getMap(resolution = "low")
plot(newmap, xlim = c(-20, 59), ylim = c(35, 71), asp = 1)
points(test$LONGITUDE, test$LATITUDE, col = "red", cex = .6)
我认为R可能无法识别这些经纬度格式? 谢谢
将坐标重新投影到纬度/经度(如果您不知道您的数据点当前在哪个坐标系中可能会很麻烦)的另一种方法是使用ggmap软件包:
library(ggmap)
#get coordinates from google maps
coords = geocode(as.character(test$Country))
#add points to map
points(coords$lon,coords$lat,col="red")
当然,由于该程序包使用Google地图查找坐标,因此仅适用于较简单的任务(例如查找国家/地区的坐标),并且您每天被api限制为最多2500个查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.