Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用geom_point()和gmap()打印点_R_Ggplot2_Qmap - Fatal编程技术网

R 使用geom_point()和gmap()打印点

R 使用geom_point()和gmap()打印点,r,ggplot2,qmap,R,Ggplot2,Qmap,我有20个UTM位置,包括在下面。 编辑我已经修改了包含的数据,以包含Lat Long中的位置,并在下面添加了其他代码。无论是UTMs还是Lat,Long,我都能得到相同的结果。我已经在google earth中仔细检查了这些点,它们肯定在我下面定义的底图范围内。任何其他建议 Data <- structure(list(Latitude = c(43.383819, 43.383787, 43.383838, 43.384088, 43.392086, 43.393099, 4

我有20个UTM位置,包括在下面。 编辑我已经修改了包含的数据,以包含Lat Long中的位置,并在下面添加了其他代码。无论是UTMs还是Lat,Long,我都能得到相同的结果。我已经在google earth中仔细检查了这些点,它们肯定在我下面定义的底图范围内。任何其他建议

    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")
但是,我想使用
qmap
在地图基础层上绘制它们,并指定了下面的对象

library(ggmap)
Area <- "palisades wyoming"
BaseMap <- qmap(Area , zoom = 10)
BaseMap 
但是得到以下警告

Removed 20 rows containing missing values (geom_point). 
为什么未使用
ggplot()
映射,而仅包含在
geom_point()

映射
ggplot()
中的点返回
ggplot()
qmap()之间的以下错误不兼容性


提前感谢。

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

qmap(Area , zoom = 10) + geom_point(aes(x = UTM_E, y = UTM_N), data = Data )
你会把地图打印出来的


祝你好运

这些值可能不在地图的边缘。使用
ggplot
时,点数据决定了绘图的限制。当您首先获取地图时,地图会设置限制,而您的数据恰好超出了这些限制,因此警告会告诉您这些限制没有打印。
ggplot
qmap
都从头开始设置打印,您无法合并它们。我认为
qmap
希望使用纬度和经度单位。您的数据是UTM格式的,所以我会先尝试转换为lat/long。事实上,
ggmap
正在寻找lat/lon。可能有助于转换。您已切换到long和lat。试试
x=Longitude,y=Latitude
,它应该会起作用。最好以打字错误的形式结束。
Removed 20 rows containing missing values (geom_point). 
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 "+" 
qmap(Area , zoom = 10) + geom_point(aes(x = UTM_E, y = UTM_N), data = Data )