4
votes

How do I get a map with in a specific minimum and maximum limits of latitude and longitude using ggmap in R?

I'm new to using ggmap, as of now I was able to implement this:

center <- c(mean(src$longitude),mean(src$latitude))
zoom <- min(MaxZoom(range(src$latitude),range(src$longitude)))
hdf <- get_map(location=center,zoom=zoom)

Help file says location can be mentioned as an address, longitude/latitude pair (in that order), or left/bottom/right/top bounding box. I couldn't find any helpful material on implementing the bounding box for ggmap online.

1

1 Answers

9
votes

I'm not sure you can do it in the download stage, but how about in the plotting stage like this:

map <- get_map()
p1 <- ggmap( map )
p2 <- ggmap( map )+
scale_x_continuous( limits = c( -95.5 , -95.3 ) , expand = c( 0 , 0 ) )+
scale_y_continuous( limits = c( 29.6 , 29.8 ) , expand = c( 0 , 0 ) )
require( gridExtra )
grid.arrange( p1 , p2 , nrow = 1 )

enter image description here