【问题标题】:Improving a location visibility using ggmap function in R使用 R 中的 ggmap 函数提高位置可见性
【发布时间】:2018-02-08 05:59:42
【问题描述】:

我正在阿联酋地图上标记一些点。我为此目的使用 ggmap 和 ggplot2 包。

我绘制和标记地图的代码是:

library(ggmap)
library(ggplot2)

d <- data.frame(lat=c(24.534505, 24.529291,24.529291, 24.543425, 24.551134, 24.555446, 24.560406, 24.558412, 24.558670, 24.548625, 24.547120, 24.540850, 24.540428, 24.534505),lon=c(55.415467, 55.419130, 55.432415, 55.465657, 55.462406, 55.473639, 55.471087, 55.465286, 55.465211, 55.438385, 55.439173, 55.427146, 55.427119, 55.415467))

map <- get_map("Sweihan, United Arab Emirates", zoom = 11, maptype = "satellite", source = "google")

Sweihan <- ggmap(map)+geom_point(data = d, aes(x = lon, y = lat))+geom_path(data = d, aes(x = lon, y = lat))+scale_x_continuous(limits = c(55.41, 55.48)) +
      scale_y_continuous(limits = c(24.52, 24.5655))
Sweihan

现在问题是在运行此代码之后,我能够获得我想要绘制的正确地图和精确点。但我不会得到地图的清晰度。我试过放大 get_map 函数,但没有帮助。 有什么方法可以在我的代码中使用来获得可见的地图。

任何帮助将不胜感激!

提前致谢!

【问题讨论】:

  • data.frame d在哪里?
  • @Richard,我在上面粘贴代码时出错了。请参阅上面的编辑代码。谢谢

标签: r ggplot2 zooming ggmap


【解决方案1】:

通过地址查找地图很方便,但如果使用经度/纬度,则控制更多

map <- get_map(location = c(mean(d$lon), mean(d$lat)), zoom = 13, maptype = "satellite", source = "google")

ggmap(map)+
  geom_point(data = d, aes(x = lon, y = lat))+
  geom_path(data = d, aes(x = lon, y = lat))

ggmap 已经设置了 x 和 y 比例,所以如果你尝试替换它们,你会收到警告。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-01-28
  • 1970-01-01
  • 2013-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多