简体   繁体   中英

get_map error in R

After a lenghty coordinate transformation, available here I want to display the area - more specifically i want to display the aerial image so i can later on use it to plot my data on.

> 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 is awfull lot, so i guess i must be doing something totally wrong. What is the problem with my code?

What is the argument expand for ? I looked up the get_map in the Help pages, but there is nothing with regard to this argument.

You mixed up your x (lon) and y (lat) coordinates.

Correct code

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

Data

(from 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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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