R: Set X and Y limits when using qmap (ggplot2) -
I am trying to create a map using qmap (part of ggmap). To illustrate through the question here is an example piece of code. It is a sort of stupid, but it is cleaner than using my own data.
install.packages ("ggmap") library (ggmap) qmap ("Capital Building, Washington DC", Zoom = 15) So my mine The question is: In the vicinity of the Capital Building I want to zoom a good bit (zoom = 15) to get lots of detail of the road. But I want to include Washington Monument in my map too. To do this, I want to expand the western part of the map and make it rectangular.
Does anyone know how to do this? Any insight would be much appreciated. Thanks for your patience with the beginning
Like this?
Library (ggmap) of cap & lt stack.imgur.com/8bbod.png geocode ("Washington Memorial, Washington DC") loc & lt; -. Unlisted ((cap + wash) / 2) ggmap (get_map (location = loc, zoom = 15)) + coord_fixed (ylim = loc [2] + 005 * c (- 1, +1)) then pulls in a map based on the coords between the Capitol Building and the Washington Monument in the middle of this path, then it by establishing trim ylim . unlist (...) The reason for this is that geocode (...) a data frame and get_map (.. ) wants a numerical vector. Edit Reply to Op's comment. One aspect ratio of coord_fixed (...) 1: 1, which means that 1 degree latitude is the same length as 1 degree latitude. To get the original aspect ratio back from the map, use coord_map (...) . ggmap (get_map (location = loc, zoom = 15)) + Coord_map (ylim = loc [2] + 005 * c (-1, + 1))
Comments
Post a Comment