R地图绘图问题

时间:2018-01-08 16:00:24

标签: r maps precision

我只是将文件中的纬度/长度绘制到R中的地图上。我遇到了一些问题,因为我绘制的点大致在正确的区域中显示 - 但对我来说不够准确。我不知道这是我的代码,谷歌地图,还是lat / longs的结果?我想我已经淘汰了后者(见下文)。

代码:

library (ggmap)
library (gdata)

whitelee_boundary <- c(left = -4.6, bottom = 55.5, right = -3.8, top = 55.8)
map2 <- get_stamenmap(whitelee_boundary, zoom = 12, maptype = "toner-lite")
ggmap(map2)

df <- read.table("WhiteleeLatLong.txt", header = FALSE)
lat=df[1]
lon=df[2]
lati=as.numeric(unlist(lat))
long= as.numeric(unlist(lon))

points(lati, long, col = "blue", cex = 1.0)

导致在非常严格(不正确)的地理范围内绘制蓝色圆圈

blue circles plotted in a very tight(incorrect) geographical range

然后,我尝试通过手动显示错误检查点:

points(55.7, -4.4, col = "blue", cex = 1.0)

这导致没有明显添加点(让我认为这是我的代码或谷歌地图的准确性)。

我原本以为这是read.table或数字转换中的精确问题,并且已经咨询过:

How to stop read.table from rounding numbers with different degrees of precision in R?

as.numeric() removes decimal places in R, how to change?

然而,似乎圆角只是美学,并且数字以必要的精度存储。

提前道歉 - 自我上次编码任务以来已经很长时间了!

编辑:当我命令

points(-4.4, 55.7, col = "blue", cex = 1.0)

输出是(忽略大圆圈):

Plot appears on map but not in correct location

0 个答案:

没有答案