繁体   English   中英

用边界坐标绘制的ggmap

[英]ggmap plotted with bounding coordinates

我正在尝试使用此处的解决方案绘制ggmap时应用坐标的边界框,因为使用边界框指定get_map()无效(转换为中心和缩放)。

但是,最终我的绘图周围有很多多余的灰色。 我想很好地拟合边界坐标为(xmin,xmax,ymin,ymax)=(-170,-30,-60,110)的图

# Get a Google satellite map of North and South America
map <- get_map(location = c(-100, 20), zoom = 2, maptype = "satellite", source = "google")
ggmap(map)

结果是: 这张地图

我想将一个图拟合到上述坐标。

# Attempt to scale the x and y axes
ggmap(map) + 
scale_x_continuous(limits = c(-170, -30), expand=c(0,0)) +
scale_y_continuous(limits = c(-60, 110), expand=c(0,0))

我最终得到的是一个看起来像这样的情节: 在此处输入图片说明

裁剪效果很好,但顶部有过多的灰色空间。

编辑:我在RStudio 1.0.136中使用R 3.3.3,以及ggmap 2.7和ggplot2 2.2.0

您试图做的事超出了地图的界限。 墨卡托式投影上的最大正/负Latitude85.0511... / -85.0511... ,因为arctan(sinh(Pi)) * 180 / Pi = 85.0511288

此代码将产生正确的结果:

ggmap(map, extent = "panel") + 
scale_x_continuous(limits = c(-170, -30), expand=c(0,0)) +
scale_y_continuous(limits = c(-60, 85), expand=c(0,0))

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM