使用geom_point()和gmap()绘制点

时间:2015-08-10 21:41:15

标签: r ggplot2 qmap

我下面有20个UTM位置。 编辑我修改了包含的数据以包含Lat Long中的位置,并在下面添加了其他代码。我用UTM或Lat,Long获得相同的结果。我已经仔细检查了google earth中的点,它们肯定在我在下面定义的BaseMap范围内。任何其他建议......

example_tag

我可以使用 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

在有用的ggmap网站linked here之后,我尝试使用以下代码在基本地图上绘制点

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

但收到以下警告

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

之间的以下错误不兼容性
qmap()

提前致谢。

1 个答案:

答案 0 :(得分:0)

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

canvasDom.getContext("webgl", {antialias : false});

您将打印地图。

祝你好运!