I'm trying to map an area by using ggmap. The problem is that ggmap only plots a square map. What I'd like to do is to expand just a little bit the map, so the map would fit perfectly. Here is my code. You can download the shapefile data here.
AMB_Contour <- readOGR(dsn = '.', layer='AMB_Contour')
myprojection_latlong <- "+proj=longlat +zone=31 +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
AMB_Contour <- spTransform(AMB_Contour, myprojection_latlong)
tract_plot <- tidy(AMB_Contour)
CenterOfMap <- geocode("41.396108,2.059348")
Ciutat_NoLabels <- get_googlemap(c(lon=CenterOfMap$lon, lat=CenterOfMap$lat),zoom = 11, maptype = "terrain", source = "google", color="bw", style=c(feature="all", element="labels",visibility="off"))
ggmap(Ciutat_NoLabels)
CityMap_NoLabels <- ggmap(Ciutat_NoLabels, extent = "device")
print(CityMap_NoLabels)
CityMapWithRoutesAndStops <- CityMap_NoLabels + geom_polygon(aes(x=long, y=lat, group=group), fill=NA, size=1.5, color='black', data=tract_plot, alpha=1)
print(CityMapWithRoutesAndStops)
In the following image the eastern part of my map doesn't fit completely. I've also tried adjusting the x-y coordinates manually but it doesn't work. I don't want to change the zoom argument because for me it's perfect, the only problem is the eastern part. Finally, I want that maptype (terrain).