R中的get_map错误

时间:2018-03-26 08:59:02

标签: r ggmap

在长度坐标转换后,可用here我想显示区域 - 更具体地说,我想显示航拍图像,以便稍后我可以使用它来绘制我的数据。

> ggmap(map)
> tschamut <- ggmap(map)+
+       scale_x_continuous(limits = c(-13.4003, -13.39943), expand = c(0, 0)) +
+       scale_y_continuous(limits = c(35.419, 35.41961), expand = c(0, 0))
Scale for 'x' is already present. Adding another scale for 'x', which will
replace the existing scale.
Scale for 'y' is already present. Adding another scale for 'y', which will
replace the existing scale.
> tschamut
Error in grid.Call.graphics(C_raster, x$raster, x$x, x$y, x$width, x$height,  : 
  cannot allocate memory block of size 16777216 Tb
In addition: Warning message:
Removed 1 rows containing missing values (geom_rect). 

16777216 Tb非常多,所以我想我必须做一些完全错误的事情。我的代码有什么问题?

expand的论点是什么?我查看了帮助页面中的get_map,但没有任何关于这个论点。

1 个答案:

答案 0 :(得分:0)

您混合了x(lon)和y(lat)坐标。

正确的代码

tschamut <- ggmap(map) +
    scale_y_continuous(limits = c(-13.4003, -13.39943), expand = c(0, 0)) +
    scale_x_continuous(limits = c(35.419, 35.41961), expand = c(0, 0))

数据

(来自your question on GIS

library(ggmap)
library(ggplot2)

# Set a range
lat <- c(-13.40025, -13.3986)                
lon <- c(35.41811, 35.42041)   

# Get a map
map <- get_map(location = c(lon = mean(lon), lat = mean(lat)), zoom = 14,
               maptype = "satellite", source = "google")