2

我在下面包含 20 个 UTM 位置。 编辑我已经修改了包含的数据以包含 Lat Long 中的位置,并在下面添加了附加代码。我使用 UTM 或 Lat, Long 得到相同的结果。我已经仔细检查了谷歌地球中的点,它们肯定在我在下面定义的 BaseMap 的范围内。还有什么建议...

    Data <- structure(list(Latitude = c(43.383819, 43.383787, 43.383838, 
43.384088, 43.392086, 43.393099, 43.388453, 43.384829, 43.399706, 
43.40308, 43.408739, 43.40765, 43.407522, 43.413508, 43.418288, 
43.416157, 43.417822, 43.417221, 43.417209, 43.417603), Longitude = c(-111.130989, 
-111.130988, -111.130996, -111.129578, -111.122884, -111.12143, 
-111.126514, -111.12809, -111.125333, -111.126616, -111.139745, 
-111.140401, -111.140614, -111.161305, -111.158135, -111.153607, 
-111.141158, -111.13867, -111.138528, -111.138884), UTM_E = c(489389.998429055, 
489390.073847615, 489389.434748439, 489504.334690555, 490047.849470232, 
490165.770080405, 489753.250369502, 489624.98731782, 489850.781221576, 
489747.455360571, 488685.407063201, 488632.089708587, 488614.819667178, 
486940.804672798, 487198.453753294, 487564.574155778, 488572.710048877, 
488774.012335271, 488785.505688775, 488756.758707237), UTM_N = c(4803447.00888757, 
4803443.45497495, 4803449.11983808, 4803476.70438902, 4804364.10875695, 
4804476.43597084, 4803961.08216192, 4803558.81058659, 4805210.65084223, 
4805585.51119635, 4806215.67635871, 4806094.82531047, 4806080.6391722, 
4806748.45554565, 4807278.81358453, 4807041.46688704, 4807224.59410279, 
4807157.51112311, 4807156.15933319, 4807199.96352795)), .Names = c("Latitude", 
"Longitude", "UTM_E", "UTM_N"), row.names = c(NA, 20L), class = "data.frame")

我可以将它们绘制在使用中ggplot

library(ggplot2)

ggplot(aes(x = UTM_E, y = UTM_N), data = Data )+ geom_point()
ggplot(aes(x = Latitude, y = Longitude), data = Data )+ geom_point()

但是,我想使用qmap并指定下面的对象将它们绘制在地图基础层上。

library(ggmap)
Area <- "palisades wyoming"
BaseMap <- qmap(Area , zoom = 10)
BaseMap 

在此处链接的有用 ggmap 站点之后,我正在尝试使用以下代码在基本地图上绘制点

BaseMap + geom_point(aes(x = UTM_E, y = UTM_N), data = Data )
BaseMap + geom_point(aes(x = Latitude, y = Longitude), data = Data )

但收到以下警告

Removed 20 rows containing missing values (geom_point). 

为什么没有映射时缺少值ggplot(),但仅包含在geom_point()

映射其中的点ggplot()会返回以下错误 incompatibility between ggplot()andqmap()

BaseMap + ggplot(aes(x = UTM_E, y = UTM_N), data = Data )+ geom_point()

Error in p + o : non-numeric argument to binary operator
In addition: Warning message:
Incompatible methods ("+.gg", "Ops.data.frame") for "+" 

提前致谢。

4

1 回答 1

0

你可以把它们结合起来。不要将地图添加到对象,只需使用 geom_point 代码调用它:

qmap(Area , zoom = 10) + geom_point(aes(x = UTM_E, y = UTM_N), data = Data )

你会得到你的地图打印。

祝你好运!

于 2017-07-27T21:48:35.560 回答